Open Report Action Cancelled

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.
 
R

Rick Brandt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

NoData Event 4
No Data Problem 2
no data message 1
Cancel = True - error 2
Error 2501 4
Annoying errer message 1
No Data in Report 2
How do I fix the "openreport action was cancelled" error? 2

Top