Listing the Objects in a Database

To get a list of the objects in a database, you iterate through each Collection object. The following example iterates through each TableDef, QueryDef, Relation, and Container object in a database, and prints the object name to the Debug window. In this example, strDbPath is the path to the database:

Dim dbs As Database
Dim tdf As TableDef, qry As QueryDef
Dim rel As Relation, ctr As Container

Set dbs = OpenDatabase(strDbPath)

Debug.Print "Tables: "
For Each tdf In dbs.TableDefs
	Debug.Print tdf.Name
Next tdf

Debug.Print "Querys: "
For Each qry In dbs.QueryDefs
	Debug.Print qry.Name
Next qry

Debug.Print "Relations: "
For Each rel In dbs.Relations
	Debug.Print rel.Name
Next rel

Debug.Print "Containers: "
For Each ctr In dbs.Containers
	Debug.Print ctr.Name
Next ctr