Search for a query name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a shared database with over a hundred queries in it. It is getting
difficult to determine if a query already exists. Is there a way to find a
query by searching the name of the query?
 
Take your pick:

Function QueryExists(strQueryName) As Boolean
Dim strWhere As String
strWhere = "([Name] = """ & strQueryName & """) AND ([Type] = 5)"
QueryExists = Not IsNull(DLookup("Id", "MSysObjects", strWhere))
End Function

Public Function QueryExists(QueryName As String) As Boolean
Dim varDummy As DAO.QueryDef
On Error Resume Next
Set varDummy = CurrentDb().QueryDefs(QueryName)
QueryExists = (Err.Number = 0)
End Function
 

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

Back
Top