VBA Access Function fExistQuery Code Only

Copy and paste this function (blue text) into a module from the Visual Basic Editor of your database.

Function fExistQuery(qName As String) As Boolean
Dim db As DAO.Database, i As Integer
Set db = CurrentDb
fExistQuery = False
For i = 0 To db.QueryDefs.Count - 1
     If LCase(qName) = LCase(db.QueryDefs(i).Name) Then
          fExistQuery = True 
          Exit For
     End If
Next i
Set db = Nothing
End Function


Popular Posts