View Full Version : Don't print if no data


ralphyehle
03-08-2006, 02:33 PM
How do I keep from printing reports that do not contain any data? I don't see the report, just send it to the printer and if it contains no data I'd rather not print it. Isn't there a simple setting to restrict printing blank reports? I am running the four reports using a macro.

I print 4 reports for each county (27 counties) if their was no action in the county all four reports are printed with no data. It is also possible for a county to have data in the first report but not the last three.

Sergeant
03-08-2006, 04:52 PM
In the report's properties sheet, under the events tab, create a new event procedure for the "On No Data" event. Put something like this in the sub that is produced in the code window:

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
MsgBox "The print action was canceled...the report contained no data"
End Sub

Pat Hartman
03-08-2006, 09:28 PM
When you cancel a macro, you get error 2501. See this post for sample error trapping:

http://www.access-programmers.co.uk/forums/showthread.php?t=103449

ralphyehle
03-09-2006, 08:43 AM
thanks for the help!