Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2501: The OpenReport action was cancelled

Status
Not open for further replies.

ClifCamp

Technical User
Jul 24, 2001
23
US
Here is the code I have in the Nodata event of my report:

MsgBox "No data matched your criteria"
Cancel = True

There is no error handling in it now because I have tried every error trapping procedure I could find and nothing stops the VBA msgbox from popping up with the 'End' and 'Debug' buttons on it.

Does anyone know why I can't trap this error? (Access 2000)

Thanks
 
Clifcamp,

You need to put the error trapping code in the code that opens your report. Something like this extract will do it:

On Error Goto Err_OpenReport

DoCmd.OpenReport "Reportname", view = acPreview
Exit Sub

Err_OpenReport:
Select Case Err.Number
Case 2501 ' no data
Resume Next
Case Else
MsgBox Err.Description
Resume Next
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top