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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access tables collection?

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi,

I was wondering if anyone could show me how to access the tables in the database, retrieve their names and names of the fields in the tables?

Thanks
 
Sub ShowTables()
Dim TblDef As TableDef
For Each TblDef In CurrentDb.TableDefs
If (TblDef.Attributes And dbSystemObject) = 0 Then
Debug.Print TblDef.Name
Dim Fld As Field
For Each Fld In TblDef.Fields
Debug.Print " " & Fld.Name
Next Fld
End If
Next TblDef
End Sub

this will not work for linked tables; for that case you need to open the other database, e.g.

Dim OtherDB as database
Set OtherDB = OpenDatabase("Blah.mdb")
for each tbldef in otherdb.tabledefs
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top