No Data in Report

  • Thread starter Thread starter Marc
  • Start date Start date
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
 
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
 
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
 
Back
Top