How do I, for a Report with No data, Give a Message and Close It?

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

Guest

When a report has no data, I would like to give the user a message and then
close the report. I tried the 'On No Data' event of the report, but I can't
close the report from there, at least not with DoCmd.close acReport.

Would appreciate any help/ideas?
 
Just cancel the No Data event, e.g.:
Private Sub Report_NoData(Cancel As Integer)
Cancel = True
End Sub

You can add a MsgBox if you want to tell the user about it.

If you opened the report programmatically, you will also need to trap error
2501 in the code that fired the OpenReport if you want to suppress that
message.
 
On the On No Data event write the code

Msgbox "No data"
cancel = true ' will close the report
 
You don't Close the report in the Report_NoData event, you Cancel the opening of
the report. Cancel = True will stop the report from opening.

When a report has no data, I would like to give the user a message and then
close the report. I tried the 'On No Data' event of the report, but I can't
close the report from there, at least not with DoCmd.close acReport.

Would appreciate any help/ideas?

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
Back
Top