I am wanting to open the database stored in the variable filename. It prints the proper full location, and has 1 table in it called TestTable, however when I execute the code below it only prints the table names of the database I am executing the code from (which has no tables). How can I change the focus to the secondary database?
Code:
Function GetTableInfo(ByVal filename As String)
Dim accapp As Access.Application
Set accapp = New Access.Application
Debug.Print (filename)
accapp.OpenCurrentDatabase (filename)
accapp.Visible = True
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
Debug.Print (tdf.name)
If Not (tdf.name Like "MSys*") Then
WriteData tdf.name, tdf.connect
End If
Next
Set tdf = Nothing
Set db = Nothing
End Function