Print several reports, unless no data

kbrooks

Still learning
Local time
Yesterday, 20:02
Joined
May 15, 2001
Messages
202
I have a macro that will open about 10 reports in the preview mode. Each report runs off it's own query. Several of the reports will have no records and therefore be blank. Currently I go to each report, print it if it has records and close it if it's blank. Which works fine. But I'm thinking there has to be a way to open the report only if it has data, and I just can't figure it out.

Any help would be much appreciated.
 
You can put

Cancel = True

in the No Data event of each report. That will throw a 2501 error back, so rather than a macro, use code to run all the reports, and trap for 2501. That should allow all the reports with data to print automatically, skipping the ones that don't.
 
Try using the On No Data event:

Code:
Private Sub Report_NoData(Cancel As Integer)

    '  MsgBox "Nothing found to print."
    Cancel = True


End Sub

In you macro or vba code that opens the report, you will need use error handling to look at the Err Code and if 2501 continue.

EDIT: Looks like I am typing to slow. Need more caffeine ....
 
Last edited:

Users who are viewing this thread

Back
Top Bottom