HELP: Run-Time Error 2501

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am constructing a form with an option group that contains a list of
reports, and on several of the reports there are parameter values that are
required. The problem I am running into is when the user cancels the action
(i.e. selected the wrong report), I get an error message that states:
"Run-Time error 2501. The OpenReport action was canceled."

How to I solve this problem?
 
Tim said:
I am constructing a form with an option group that contains a list of
reports, and on several of the reports there are parameter values
that are required. The problem I am running into is when the user
cancels the action (i.e. selected the wrong report), I get an error
message that states: "Run-Time error 2501. The OpenReport action was
canceled."

How to I solve this problem?

Use error-handling in the procedure that call DoCmd.OpenReport to trap
that error and ignore it. For example,

'----- start of example code -----
On Error GoTo Err_Handler

' ...

DoCmd.OpenReport "foo"

Exit_Point:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End If
Resume Exit_Point

End Sub
'----- end of example code -----
 
Back
Top