Jerry said:
how to find if there is a query "qryname" existing in current access DB?
TIA
Jerry
Jerry, you need to interact with the Access collection object. Place the
following code in a Module. Save the module and use the function anywhere by
typing DoesQueryExist("Query1"). The function will return True if yes or
False if "Query1" does not exist within the current database.
Public Function DoesQueryExist(qryname As String) As Boolean
Dim qry As AccessObject
Dim dbs As Access.CurrentData
Set dbs = Application.CurrentData
For Each qry In dbs.AllQueries
If qry.Name = qryname Then
DoesQueryExist = True
Exit For
End If
Next qry
End Function