How do you list all tables in a database? Was going to make a query to do this then it dawned on me i dont know how!
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Quick Question- How do you list all tables in … (Access)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Quick Question- How do you list all tables in … (Access)
- This topic has 24 replies, 10 voices, and was last updated 17 years, 6 months ago.
AuthorTopicWSCryptic80
AskWoody LoungerMarch 17, 2003 at 2:43 am #384831Viewing 1 reply threadAuthorReplies-
WSCryptic80
AskWoody Lounger -
WSpatt
AskWoody Lounger -
WSD Willett
AskWoody LoungerMarch 17, 2003 at 7:53 am #661600Try this.
It will return all tables, whether networked or not, and count all entries also.
SELECT [MsysObjects].[Name], DCount(“*”,[Name]) AS TableCount
FROM MsysObjects
WHERE (((Left$([Name],1))”~”) And ((Left$([Name],4))”Msys”) And (([MsysObjects].[Type])=1 Or ([MsysObjects].[Type])=6))
ORDER BY [MsysObjects].[Name]; -
WSCryptic80
AskWoody Lounger -
WSHansV
AskWoody Lounger
-
-
WSIndyAries
AskWoody Lounger -
WSHansV
AskWoody LoungerMarch 19, 2003 at 9:20 pm #662380Hi Bob,
You can view hidden and/or system objects (this is not the same) by selecting Tools/Options…, view tab. There are separate check boxes for hidden objects and system objects.
Here is a list of types to use in queries that list objects:
Object Type Table 1 Linked table 6 Query 5 Form -32768 Report -32764 Macro -32766 Module -32761 Data Access Page -32756 -
WSMarkD
AskWoody LoungerMarch 20, 2003 at 1:07 am #662436More trivial nitpicking: Type 6 = ISAM Linked tables, while Type 4 = ODBC Linked Tables. Type 5, Queries, includes SQL statements used as RecordSource or RowSource properties (included in MSysObjects for optimization purposes). These can be identified by Flags field = 3 when querying MSysObjects table for Type = 5, and thus be excluded by specifying that Flags 3 in query criteria. Since System tables are officially undocumented, the usual caveats apply, tho AFAIK the “Type” numbers used to identify database objects work same in A97, A2K, and AXP.
-
WSHansV
AskWoody Lounger -
WSIndyAries
AskWoody LoungerMarch 20, 2003 at 11:23 am #662567 -
WSHansV
AskWoody LoungerMarch 20, 2003 at 11:26 am #662570I don’t think you can get the descriptions from the MSysObjects table. You will have to loop through all objects in the collection of tables (or queries, …)
You can do this with DAO, or with the AllTables etc. collections available in Access 2000 and higher. If you want to get an idea of how to do this, take a look at the Documenter database from Access moderator MarkLiquorman. You will find a link to his web site in his profile.
But it is going to be a lot of work. Can you use Tools/Analyze/Documentation instead? Study the various options to see if it will work for you.
-
WSIndyAries
AskWoody Lounger -
WSMarkD
AskWoody LoungerMarch 20, 2003 at 1:18 pm #662600If interested this function use DAO methods to get Description property (if any) for specified database object. This function can be used in query based on MSysObjects table to list Description for each object type specified in query. Example:
Option Compare Database
Option ExplicitEnum DbObject
Table = 1
Query = 2
Form = 3
Report = 4
Macro = 5
Module = 6
End EnumPublic Function daoGetObjDescription(strObjName As String, intObjType As DbObject) As String
On Error GoTo Err_Handler‘ intObjType: see DbObject Enum for valid arg values
Dim db As DAO.Database
Dim doc As DAO.Document
Dim strContainer As String
Dim strMsg As StringSet db = CurrentDb
Select Case intObjType
Case 1, 2
strContainer = “Tables”
Case 3
strContainer = “Forms”
Case 4
strContainer = “Reports”
Case 5
strContainer = “Scripts”
Case 6
strContainer = “Modules”
End Selectdb.Containers(strContainer).Documents.Refresh
Set doc = db.Containers(strContainer).Documents(strObjName)
daoGetObjDescription = doc.Properties(“Description”)Exit_Sub:
Set db = Nothing
Set doc = Nothing
Exit Function
Err_Handler:
Select Case Err.Number
Case 3265 ‘ Item not found in collection
strMsg = “Invalid object name – object not found in specified database container.”
MsgBox strMsg, vbExclamation, “OBJECT NOT FOUND”
Resume Exit_Sub
Case 3270 ‘ Property not found:
daoGetObjDescription = “”
Resume Exit_Sub
Case Else
strMsg = “Error No ” & Err.Number & “: ” & Err.Description
Beep
MsgBox strMsg, vbExclamation, “GET OBJECT DESCRIPTION ERROR”
Resume Exit_Sub
End SelectEnd Function
Example of use in query (list all forms in current db):
SELECT MSysObjects.Name AS [Object Name], daoGetObjDescription([Name],3) AS Description, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;NOTE: This will not exactly be lightning-quick in query, as function runs once for each row returned by query. If this is issue you can always create your own table to store object info, but you’d need a reliable method to keep table updated. If no description has been entered for object, function returns a zero-length string. Also note use of user-defined Enum in Declarations section of sample code, this helps avoid errors by providing “Intellisense” list of valid arguments when using function in VBA – see attd screen shot of use in Immediate window. If using this code, ensure reference to DAO library is set.
HTH
-
WSSupport4John
AskWoody LoungerDecember 16, 2007 at 2:16 pm #1088566 -
WSHansV
AskWoody Lounger -
WSSupport4John
AskWoody Lounger -
WSHansV
AskWoody Lounger -
WSSupport4John
AskWoody LoungerDecember 17, 2007 at 3:22 pm #1088692My query contains all Object Types, tables, queries, forms, reports, ect
When I use
SELECT MSysObjects.Type, MSysObjects.Name, daoGetObjDescription([Name]) AS Description FROM MSysObjects ORDER BY MSysObjects.Type, MSysObjects.Name;
I Get Wrong number of arguments used with function in query expression daoGetObjDescription([Name])
daoGetObjDescription([Name]) is looking for the Object Type to return the description
John
-
WSHansV
AskWoody Lounger -
WSSupport4John
AskWoody LoungerDecember 17, 2007 at 4:19 pm #1088710This works, thanks for your help
John
SELECT MSysObjects.Type, MSysObjects.Name, daoGetObjDescription([Name], IIf([type]=-32768,3, IIf([type]=-32766,5, IIf([type]=-32764,4, IIf([type]=-32761,6, IIf([type]=1,1, IIf([type]=6,1, IIf([type]=5,2,2)))))))) AS Description FROM MSysObjects WHERE (((MSysObjects.Type)=-32768)) OR (((MSysObjects.Type)=-32766)) OR (((MSysObjects.Type)=-32764)) OR (((MSysObjects.Type)=-32761)) OR (((MSysObjects.Type)=1)) OR (((MSysObjects.Type)=6)) OR (((MSysObjects.Type)=5)) ORDER BY MSysObjects.Type, MSysObjects.Name;
-
WScharlotte
AskWoody Lounger
-
-
-
-
-
WSDrew
AskWoody LoungerDecember 21, 2007 at 11:55 pm #1089513A lot of methods posted. Personally, I prefer the ADO method (which will work for tables and queries):
Function GetDBTables()
On Error GoTo ErrorHandler
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
If DBConnect(cnn) Then
Set rs = cnn.OpenSchema(adSchemaTables)
Me.lstTables.Clear
rs.MoveFirst
Do Until rs.EOF = True
If Me.optTables Then
If rs.Fields(“TABLE_TYPE”) = “TABLE” Then Me.lstTables.AddItem rs.Fields(“TABLE_NAME”)
Else
If rs.Fields(“TABLE_TYPE”) = “VIEW” Then Me.lstTables.AddItem rs.Fields(“TABLE_NAME”)
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End If
Exit FunctionErrorHandler:
Err.Clear
End FunctionThis is right out of an application I wrote that builds classes in ASP from tables/queries. It’s displaying them in a listbox. And there are option buttons to display tables, or to display queries. The function DBConnect is essentially:
Function DBConnect(ByRef cnn as ADODB.Connection)
set cnn=new ADODB.connection
cnn.Provider=”Microsoft.Jet.OLEDB.4.0″
cnn.Open “C:SomePathSomeDatabase.mdb”
Exit functionHowever, you can connect that ‘cnn’, the connection object, to any database you want (Access, SQL Server, Oracle, etc), and it will list the tables for you.
-
WSWebGenii
AskWoody Lounger -
WSDrew
AskWoody Lounger
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
How get Group Policy to allow specific Driver to download?
by
Tex265
42 minutes ago -
AI is good sometimes
by
Susan Bradley
1 hour, 50 minutes ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
2 hours, 52 minutes ago -
LibreOffice 25.8. No Windows 7, 8/8.1, x86
by
Alex5723
1 hour ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
21 hours, 51 minutes ago -
June KB5060842 update broke DHCP server service
by
Alex5723
20 hours, 23 minutes ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
1 day ago -
Excessive security alerts
by
WSSebastian42
1 hour, 22 minutes ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
1 day, 9 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
50 seconds ago -
Seconds are back in Windows 10!
by
Susan Bradley
21 hours, 2 minutes ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
3 hours, 36 minutes ago -
OS news from WWDC 2025
by
Will Fastie
58 minutes ago -
Need help with graphics…
by
WSBatBytes
5 hours, 12 minutes ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
2 days, 1 hour ago -
Totally remove or disable BitLocker
by
CWBillow
1 day ago -
Windows 10 gets 6 years of ESU?
by
n0ads
1 day, 3 hours ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
2 days, 12 hours ago -
Search Forums only bring up my posts?
by
Deo
6 hours, 34 minutes ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
2 days, 23 hours ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
2 days, 16 hours ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
3 days ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
3 days, 10 hours ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
3 days, 11 hours ago -
Disengage Bitlocker
by
CWBillow
3 days, 1 hour ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
3 days, 13 hours ago -
New Win 11 Pro Geekom Setup questions
by
Deo
6 hours, 39 minutes ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
3 days, 20 hours ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
3 days, 20 hours ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
4 days ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.