Check if Query exits (1 Viewer)

pekajo

Registered User.
Local time
Today, 21:31
Joined
Jul 25, 2011
Messages
132
Hi,
Is there an easy way of checking via VB if a query exists?
Regards
Peter
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 06:31
Joined
Apr 27, 2015
Messages
6,280
Good morning,

Have a look at the IsObject() method. I believe the syntax you need is:

Code:
IsObject(CurrentDb.QueryDefs("qryName")

This will return True if is exists, False if not. To use, you would do something like this:

Code:
If IsObject(CurrentDb.QueryDefs("qryName") Then
    Do something
End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:31
Joined
May 7, 2009
Messages
19,169
or you can query the msysObjects table.
if the return value is not 0, the query exists:
Code:
debug.print DCount("1", "MsysObjects", "Name='" & strQueryName & "' And Type=5")
 

Users who are viewing this thread

Top Bottom