Code to get all table names in a database

G

gavin

Looking for an easy way to programtically get the names of all tables in a databas

Thanks
 
S

Steven

Dim tTables As TableDef

For Each tTables In CodeDb.TableDefs
Debug.Print tTables.Name
next
 
A

Allen Browne

Another alternative:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY MsysObjects.Name;
 
D

Douglas J. Steele

I believe you also need to look at Type = 4 and Type = 6 if you want all of
the table objects.

Type = 1 will only give you tables that exist in the database. Type = 6 will
give you linked tables, and Type = 4 will give you ODBC-linked tables.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Allen Browne said:
Another alternative:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY MsysObjects.Name;

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Steven said:
Dim tTables As TableDef

For Each tTables In CodeDb.TableDefs
Debug.Print tTables.Name
next
in
a
database
 

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