Code to get all table names in a database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Thanks
 
Dim tTables As TableDef

For Each tTables In CodeDb.TableDefs
Debug.Print tTables.Name
next
 
Another alternative:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY MsysObjects.Name;
 
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
 
Back
Top