No Data in Report

M

Marc

Dear All,

using the following code in the OnNoData event:
MsgBox"There is NO Data in the Report"
Cancel=True

this cancel the report, nevertheless a second message is shown:

"The action OpenReport has been cancelled"

How can I avoid the second popup message?

Thanks in advance,

Marc
 
F

fredg

Dear All,

using the following code in the OnNoData event:
MsgBox"There is NO Data in the Report"
Cancel=True

this cancel the report, nevertheless a second message is shown:

"The action OpenReport has been cancelled"

How can I avoid the second popup message?

Thanks in advance,

Marc

That is a normal error if the report has been opened by code from a
form event. Simply trap the error (2501) in that event.

Code the Form's Command button click event that opened the report:

On Error Goto Err_Handler
DoCmd.OpenReport "ReportName" etc...

Exit_This_Sub:
Exit Sub

Err_Handler:
If Err = 2501 then
Else
MsgBox "Error " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
 
M

Marc

That is a normal error if the report has been opened by code from a
form event. Simply trap the error (2501) in that event.

Code the Form's Command button click event that opened the report:

On Error Goto Err_Handler
DoCmd.OpenReport "ReportName" etc...

Exit_This_Sub:
Exit Sub

Err_Handler:
If Err = 2501 then
Else
MsgBox "Error " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub

Thanks Fred,
you are Great, everything works well!!
Kind regards,
Marc
 

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

Cancel = True - error 2
no data message 1
Don't want to print a report with no data 1
Error 2501 7
Annoying errer message 1
Report OnNoData event error 2
No data report 2
On No Data doesn't work -Access 97 1

Top