Search for a query name

B

brimile

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?
 
A

Allen Browne

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
 
Top