Link to home
Start Free TrialLog in
Avatar of Lethal_J
Lethal_JFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Listing Tables Using ADO or DAO

Hello,

Ive been contracted to write a program to update the data structures and tables of an Access database when the client deploys an updated version of their software.  This will run initially and upgrade the database with the latest fields and tables as required.

However, im a little stumped as to how to read the table names from the MDB file.  I cannot use constants for the table names in this case as the client will be using this program on several other projects as well.

Is there a way to list the tables of an Access database using either ADO or DAO, or is there perhaps another method which I am overlooking?

Thanks for your help.
SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Doodle
Doodle

The following code will list all the object name from the msysobjects table all you will need to do is create an connection to the db.

Public Sub listtablenames()
    Dim RS As New ADODB.Recordset
    RS.Open "Select * from msysobjects", CN
        Do Until RS.EOF
            Debug.Print RS("Name")
            RS.MoveNext
        Loop
    RS.Close
End Sub