Checking for query from code on new query

T

Tony Vrolyk

I am using the following code to check the existance of a query. However it
seems that it only returns true on a new query after closing the db and
reopening? Is there a way around this?


Public Function fDoesQueryExist(strQueryName As String) As Boolean
Dim db As Database
Dim qdf As QueryDef
Set db = DBEngine(0)(0)
fDoesQueryExist = False
For Each qdf In db.QueryDefs
If qdf.Name = strQueryName Then fDoesQueryExist = True
Next qdf
Set db = Nothing
End Function


Thanks
Tony Vrolyk
 
C

Chris Nebinger

After the line:
Set db = DBEngine(0)(0)

Add:
db.QueryDefs.Refresh

Chris Nebinger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top