VBA Access Function fncDeleteQuery Code Only

This is code only, to learn more see this post:

            VBA Access Function fncDeleteQuery Tutorial

Copy and paste these two functions (blue text) into a module from the Visual Basic Editor of your database.

Function fncDeleteQuery(qName As String)
If fExistQuery(qName) = True Then DoCmd.DeleteObject acQuery, qName
End Function

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