DAO

E

EGeorge

Using VBA, how would I build a list of tables that exist
in an .mdb file OTHER than the one in which I am working?
 
C

Cameron Sutherland

Just replace the msgbox with a string or array or whatever
you want to store values in.

Dim db As Database
Dim varTable As Variant
Set db = CurrentDb
For Each varTable In db.TableDefs
If Len(varTable.Connect) > 1 Then
msgbox "Linked table: " & varTable.Name
Else
msgbox "Local table: " & varTable.Name
End If
Next
db.Close
Set db = Nothing

-Cameron Sutherland
 
D

Douglas J. Steele

Something like the following untested aircode should do it:

Dim db As Database
Dim tdf As TableDef

Set dbCurr = OpenDatabase("C:\My Documents\MyDatabase.mdb")
For Each tdf In dbCurr.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
Debug.Print tdf.Name
End If
Next tdf

Set tdf = Nothing
Set dbCurr = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top