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
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.