Listing tables from different DB

  • Thread starter Thread starter Del
  • Start date Start date
D

Del

I'm using Access 2000 and I want to fill a combo box list with the tables
from another database so my user can select which table to import.
 
I'm using Access 2000 and I want to fill a combo box list with the tables
from another database so my user can select which table to import.


Let's assume the combo box name is "cboTableList".
Set the Combo box's RowsourceType property to Value List.
Leave the Rowsource blank.

Paste the following into a new module.

Function GetDiffDbTableNames()
Dim wrkJet As Workspace
Dim Db As DAO.Database
Dim tdf As TableDef
Dim strList As String
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)

Set Db = wrkJet.OpenDatabase("c:\MyFolder\MyDatabaseName.mdb", False)

For Each tdf In Db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
strList = strList & tdf.Name & ","
End If

Next
strList = Left(strList, Len(strList) - 1)
GetDiffDbTableNames = strList
Set Db = Nothing
wrkJet.Close
End Function
 
Back
Top