Query to List Tables

B

Brad Newman

I believe there is a way to run a query against the
current database that will list all the tables in that
database. Can anyone tell me what the name of the table
is that I would write the table against?

Thanks.
 
G

Gary Walter

Brad Newman said:
I believe there is a way to run a query against the
current database that will list all the tables in that
database. Can anyone tell me what the name of the table
is that I would write the table against?
Hi Brad,

I believe this is what you are asking for:

SELECT MSysObjects.Name AS TableName
FROM MSysObjects
WHERE (((MSysObjects.Type)=1)
AND ((MSysObjects.Flags)=0));

Please respond back if I have misunderstood.

Good luck,

Gary Walter
 
J

Joe Fallon

In 2002, there are some nice collections that can be accessed from
CurrentProject and CurrentData.
CurrentData includes: AllQueries, AllTables
CurrentProject includes: AllForms, AllReports, AllMacros, AllModules,
AllDataAccessPages

Here is how to list all tables:

Public Sub ListTables()
Dim obj As AccessObject
With CurrentData
For Each obj in .AllTables
Debug.Print " " & obj.Name
Next obj
End With
End Sub

Public Sub ListModules()
Dim obj As AccessObject
With CurrentProject
For Each obj In .AllModules
On Error Resume Next
Debug.Print " " & obj.Name
Next obj
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top