Open Report Action Cancelled

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

On Nodata event, after I run a message saying there is no
data for the specified range, I use docmd.cancelEvent to
cancel the report opening. A message comes up saying "The
OpenReport Action was cancelled".

How do I prevent this message from displaying?

Thanks in advance for your help.
 
Anne said:
On Nodata event, after I run a message saying there is no
data for the specified range, I use docmd.cancelEvent to
cancel the report opening. A message comes up saying "The
OpenReport Action was cancelled".

How do I prevent this message from displaying?

The code that is causing the report to be opened needs to have an error
handler. In that error handler you can test the error number and ignore
when it is 2501.

EX:

On Error GoTo ErrHandler

DoCmd.OpenReport "ReportName"

Egress:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
'ignore
Case Else
(your normal error handling code)
End Select
Resume Egress
End Sub
 
Back
Top