List Objects

aardvark
Lounger
Posts: 47
Joined: 09 Feb 2010, 11:30
Location: OH USA

List Objects

Post by aardvark »

Is there a utility/routine available that will list the objects in a database, specifically the queries and reports? TIA.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: List Objects

Post by HansV »

To list the names of all queries, you can create a query with this SQL:

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

and use it as the row source for a list box or combo box, or the record source for a form or report.

For reports, change the SQL to

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

Others: Tables have type 1, Forms have type -32768 and Modules have type -32761.
Best wishes,
Hans

aardvark
Lounger
Posts: 47
Joined: 09 Feb 2010, 11:30
Location: OH USA

Re: List Objects

Post by aardvark »

Thanks, Hans. Just what I needed.