Cancel the printing of a report when it doesn't contain any records
- Open the report in Design view.
- Double-click the report selector to display the report's property sheet.
- Set the OnNoData property to [Event Procedure] or to the name of a macro that cancels previewing or printing the report.
- If you use a macro, use the MsgBox action to display a message that describes why there is no data for the report, and use the CancelEvent action to cancel printing or previewing the report. For information on creating a macro, click .
- If you use an event procedure, use the MsgBox statement to display a message, and set the Cancel argument of the Report_NoData Sub procedure to True. For information about customizing an event procedure, click .
Note The Employee Sales by Country report in the Northwind sample database uses an event procedure in the OnNoData property. To view this report, open the Northwind database in the Samples subfolder of your Office folder, and then open the Employee Sales by Country report in Design view. For information on opening Northwind, click .