jfkiser has the right idea. Assuming the button to run this query was generated by the command button wizard, you've got an error handler at the bottom of your sub. Your sub should look something like this, where the name of your command button should be everywhere that you see RunYourQuery in this code.
[CODE=vb]Private Sub RunYourQuery_Cl ick()
On Error GoTo Err_RunYourQuer y_Click
Dim stDocName As String
stDocName = "YourQueryN ame"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_RunYourQue ry_Click:
Exit Sub
Err_RunYourQuer y_Click:
If Err.Number = 2501 Or Err.Number = 2001 Then
Resume Exit_RunYourQue ry_Click
Else
MsgBox Err.Description
Resume Exit_RunYourQue ry_Click
End If
End Sub[/CODE] To turn the error message off (which you said you wanted to do) for this problem but leave other error detection intact, replace the error handler with Lines # 12 - 18, as above.
Amazingly, if you only trap error 2501, Access will sometime, not always, throw a second error, 2001, which also means that an operation has been cancelled.
Linq ;0)>
[CODE=vb]Private Sub RunYourQuery_Cl ick()
On Error GoTo Err_RunYourQuer y_Click
Dim stDocName As String
stDocName = "YourQueryN ame"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_RunYourQue ry_Click:
Exit Sub
Err_RunYourQuer y_Click:
If Err.Number = 2501 Or Err.Number = 2001 Then
Resume Exit_RunYourQue ry_Click
Else
MsgBox Err.Description
Resume Exit_RunYourQue ry_Click
End If
End Sub[/CODE] To turn the error message off (which you said you wanted to do) for this problem but leave other error detection intact, replace the error handler with Lines # 12 - 18, as above.
Amazingly, if you only trap error 2501, Access will sometime, not always, throw a second error, 2001, which also means that an operation has been cancelled.
Linq ;0)>
Comment