Hi, Is there an easy way of checking via VB if a query exists? Regards Peter
P pekajo Registered User. Local time Today, 16:11 Joined Jul 25, 2011 Messages 133 Aug 18, 2019 #1 Hi, Is there an easy way of checking via VB if a query exists? Regards Peter
NauticalGent Ignore List Poster Boy Local time Today, 02:11 Joined Apr 27, 2015 Messages 6,382 Aug 18, 2019 #2 Good morning, Have a look at the IsObject() method. I believe the syntax you need is: Code:Copy to clipboard IsObject(CurrentDb.QueryDefs("qryName") This will return True if is exists, False if not. To use, you would do something like this: Code:Copy to clipboard If IsObject(CurrentDb.QueryDefs("qryName") Then Do something End If
Good morning, Have a look at the IsObject() method. I believe the syntax you need is: Code:Copy to clipboard IsObject(CurrentDb.QueryDefs("qryName") This will return True if is exists, False if not. To use, you would do something like this: Code:Copy to clipboard If IsObject(CurrentDb.QueryDefs("qryName") Then Do something End If
arnelgp ..forever waiting... waiting for jellybean! Local time Today, 14:11 Joined May 7, 2009 Messages 19,246 Aug 18, 2019 #3 or you can query the msysObjects table. if the return value is not 0, the query exists: Code:Copy to clipboard debug.print DCount("1", "MsysObjects", "Name='" & strQueryName & "' And Type=5")
or you can query the msysObjects table. if the return value is not 0, the query exists: Code:Copy to clipboard debug.print DCount("1", "MsysObjects", "Name='" & strQueryName & "' And Type=5")