View Full Version : load tables from different database


tomro1
12-10-2007, 10:29 AM
hi,

This is the code that i used to get my tablenames into a combobox:

Dim STRtables As String
Dim obj, obj1 As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
If STRtables = "" Then
STRtables = obj.Name
Else
STRtables = STRtables + ";" + obj.Name
End If
Next obj
combobox.RowSource = STRtables


Now i need to get into the combobox, the tables from a different database, so that i can see what tables there are in another database.
can anyone help me find out how i can do this?

thanks in advance

WayneRyan
12-10-2007, 12:51 PM
t,

You can use the mSysObjects table in either database to get a list of the tables.

For the external DB:


Select Name
From mSysObjects In 'C:\SomeDatabase.mdb'
Where Type In (1, 2, ...) <-- Don't know off-hand, you'll have to research


I posted a sample database "MDB Comparison", it has a few examples of working
with tables in an external DB.

Wayne