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!

Looping through tables in an another mdb file 1

Status
Not open for further replies.

teach314

Technical User
Joined
Jul 29, 2011
Messages
183
Location
CA
here is some code to loop through the tables in the current db.

Code:
   Dim db As DAO.Database
   Dim tdf As DAO.TableDef
   Set db = CurrentDb
   For Each tdf In db.TableDefs
      If Not (tdf.name Like "MSys*" Or tdf.name Like "~*") Then
         Debug.Print tdf.name
         
         ... DO STUFF HERE ...

      End If
   Next
   Set tdf = Nothing: Set db = Nothing

I want to write a similar function, but I want to list the tables in another mdb file on an external drive.
The full Path and Name of the external file is in the variant varPathName....

eg: varPathName = "E:\2012_ARCHIVE\Semester_1\CurriculumGuides.mdb".
From the mdb file I'm currently running, I want to loop through the tables in varPathName.

I assume I need to change the code line "Set db = CurrentDb" to something else so that the code looks at the TableDefs in the external mdb file, but I can't get the syntax right. Any hints?

Thanks in advance

 
exactly what was needed. Thanks!
 
I doubt you can connect to an Access database file on a web server like this.

BTW: always include the complete error message rather than "gives an error".

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top