Hello to All,
I have written the following code for checking whether a query exists.
Here I try to intercept the error message in vain. What am I missing here? Can somebody help please?
I have written the following code for checking whether a query exists.
Code:
Function QueryExists(strQueryName As String) As Boolean
'----------------------------------------------------------------------------------------
' Checks whether a query already exists
'----------------------------------------------------------------------------------------
Dim db As DAO.Database
Dim tdf As DAO.QueryDef
On Error GoTo err_handler
Set db = CurrentDb
Set tdf = db.QueryDefs(strQueryName)
QueryExists = True
QueryExists_Exit:
Exit Function
err_handler:
If Err.Number = 3265 Then
QueryExists = False
Resume QueryExists_Exit
Else
MsgBox Err.Description, vbExclamation, "Error #: " & Err.Number
QueryExists = False
Resume QueryExists_Exit
End If
End Function