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

Read all Table names function

Status
Not open for further replies.

chris9

Programmer
Feb 11, 2003
32
US
Does anyone know if there is a function that can List all the Tables you have in one Database?
 
As a query:

SELECT MSysObjects.Database, MSysObjects.Connect, MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Type)=6));

or:

Sub ListTables(strDbPath As String)
' This procedure lists the tables in a database.
' Arguments:
' strDbPath: The path to the database.

Dim dbs As DATABASE, tdf As TableDef

Set dbs = OpenDatabase(strDbPath)
For Each tdf In dbs.TableDefs
Debug.Print tdf.NAME
Next tdf
dbs.close
Set dbs = Nothing
End Sub
 
Something along these lines...?

Public Sub ListTables()

Dim daoDB As DAO.Database
Dim daoTDF As DAO.TableDef

Set daoDB = CurrentDb()

For Each daoTDF In daoDB.TableDefs
Debug.Print daoTDF.name
Next daoTDF

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top