Cancel report with no record.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Can anyone tell me how to cancel report if there is no record? I don't like to see a report with error on record fields

Thank you for your time.
 
add the following event procedure to the report's module, as

Private Sub Report_NoData(Cancel As Integer)

Cancel = True
MsgBox "Request cancelled - no data available."

End Sub

hth


Stephen said:
Hi.

Can anyone tell me how to cancel report if there is no record? I don't
like to see a report with error on record fields.
 
Also note that, if you're opening the report from a macro or VBA code, Error
2501 will be returned by the report to the procedure that opened the report.
If you don't want to see the ACCESS warning "The previous action has been
canceled.", you'll need to trap for this error and stop the error message
from appearing.

E.g.,

DoCmd.OpenReport "ReportName"
If Err.Number <> 2501 And Err.Number <> 0 Then
MsgBox "Error occurred"
End If
 
oops, forgot that not-so-minor point. thanks for picking up the slack, Ken!
:)
 

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

Back
Top