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

Getting table names in external db 1

Status
Not open for further replies.

bbarr

Programmer
Sep 15, 2003
51
US
I'm using Access 2000.

I'm trying to set a connection to another .mdb file and programmatically set links to all tables in that file.

If the second .mdb file is "d2.mdb" and located in "C:\" then how do I access the TableDefs collection of this database?
 
Try something like:

Dim dbs as DAO.Database
Dim tdf as DAO.Tabledef

Set dbs = "C:\db2.mdb"

For Each tdf In dbs.TableDefs
...
Next tdf

Set tdf = Nothing
Set dbs = Nothing

Good luck

-Gary
 
Thanks.

However, I'm getting a type mismatch error.

I have the path/name of the file set to a string variable (pName) and therefore rewrote

Set dbs = "C:\db2.mdb"

to

Set dbs = pName

and this is giving me the error.

 
I found the answer ... looking at some related code.

you have to use:

Set dbs = OpenDatabase(pName)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top