DAO

  • Thread starter Thread starter EGeorge
  • Start date Start date
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?
 
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
 
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
 
Back
Top