Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2002 Cannot Access Fields 1

Status
Not open for further replies.

SpankYou

Programmer
Feb 24, 2003
211
GB
I have this code which I have adapted from the microsoft website, basically this should put all the tables names in one listbox and all field names in another. The table names work but the Field names doesn,t. I'm not quite sure what I'm doing wrong, the code doesn't error, but when I put the mouse over the fs.Name on the line...

strFName = fs.Name

It comes up with "Object Variable or With Block Variable Not Set"

Code Below...

Any Ideas?

Cheers


Sam


Dim db As Database 'Database to import
Dim td As TableDef 'Tabledefs in db
Dim fs As Field 'Fields In TabelDefs

Set db = DBEngine.Workspaces(0).OpenDatabase(strPath, True)

For Each td In db.TableDefs

strTDef = td.Name

If Left(strTDef, 4) <> &quot;MSys&quot; Then

Me.LstTable.AddItem strTDef

For Each fs In td.Fields

strFName = fs.Name

Me.LstField.AddItem strFName
Next fs

&quot;You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine.&quot; - Homer
 
Try changing your dim statement to specify a DAO object:

Dim fs As DAO.Field 'Fields In TabelDefs

Hope this helps.

Glen

VB.Net student.
 
Hey,

Worked a treat BuGlen thanks for the help, and hope you enjoy the star!

Cheers

Sam

&quot;You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine.&quot; - Homer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top