How to tell if a Query Exists

catbeasy

Registered User.
Local time
Today, 03:26
Joined
Feb 11, 2009
Messages
140
Was wanting to get some help on how to use code to test if a query exists..Any suggestions?

Thanks..
 
This should work

Code:
dim qdf as DAO.querydef

' loop thru all querydefs in db
for each qdf in currentdb.querydefs
[INDENT]debug.print qdf.name[/INDENT]
[INDENT]if qdf.name = "your-query-name" then[/INDENT]
[INDENT][INDENT]' you've found it![/INDENT][/INDENT]
[INDENT]end if[/INDENT]
loop

HTH
 
And modifying the first example from Banana's link:

Code:
SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name)=[COLOR="Red"][Query Name][/COLOR]) AND ((Left$([Name],1))<>"~") AND ((MsysObjects.Type)=5))
ORDER BY MsysObjects.Name;

Will prompt you for the query name you are looking for.

Bob
 

Users who are viewing this thread

Back
Top Bottom