Trapping 2101 Error

Novice1

Registered User.
Local time
Yesterday, 21:47
Joined
Mar 9, 2004
Messages
385
I have a form with an option that runs queries to filter the view. Case 3 asks for information from the user [TechnicianName]. If the tech's name is provided everything works fine. However, if the user cancels the msgbox then I get a 2101 error. I tried trapping the error but this too was unsuccessful.


On Error GoTo Error_Handler

Select Case Frame364

Case 1: 'Open
RecordSource = "qryPCSTrackerOpen"

Case 2: 'Closed
RecordSource = "qryPCSTrackerClosed"


Case 3: 'Tech
RecordSource = "qryPCSTrackerTech"


Case Else: 'Default case to trap any errors.
'Do nothing

End Select


Error_Handler_Exit:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit


===================

Error_Handler:
If Err.Number=2101 Then
'ignore or message
Else
MsgBox Err.Description
End If
 
Instead of


Code:
Error_Handler_Exit:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit


===================

Error_Handler:
If Err.Number=2101 Then
'ignore or message
Else
MsgBox Err.Description
End If

Try

Code:
Error_Handler_Exit:
   Exit Sub

Error_Handler:

   If Err.Number=2101 Then
        'ignore or message
   Else
        MsgBox Err.Description
    End If
    Resume Error_Handler_Exit

End Sub
 
do you mean a 2501 error? that's the standard "cancel" error?

generally you can dismiss a 2501 error, but in some cases it may be important. take this

docmd.openreport "myreport"

if myreport doesn't open you get a 2501 error.

One reason might be that there is no data, and you cancel the report opening - that's a 2501 error which you can safely dismiss.

However another reason might be that the query source for the report is faulty- that's a 2501 error also.
 

Users who are viewing this thread

Back
Top Bottom