how not to print an empty report?

Gkirkup

Registered User.
Local time
Today, 09:34
Joined
Mar 6, 2007
Messages
628
I have a report with a subreport. Sometimes the subreport has no data, in which case I don't want the report to print at all.
How do I do that? Do I put a DoCmd.Close into the On No Data area of the main report, or the subreport? Or do I need to do something else?

Robert
 
When there is no data on the subreport is there also no data on the main report?
 
There will always be header information on the main report. When there is no data on the subreport, then I don't want to print the report.

Robert
 
Try this…

Add *txtHasData* to your Main report. Make it unbound so nothing ever shows in it. Then put...

Code:
If Me.[B]YourSubReport[/B].Report.HasData Then
     Me.txtHasData.Visible = True
Else
     MsgBox "No data to Display", vbOKOnly, "Report"
     Cancel = True
End If

...in the *On_No_Data* event of the Main Report
 
Gina: This is an unattended report - it prints to a printer in another building as part of a process. So I definitely need the report to not print, not to give a message.

Robert
 
Gina: So if Hasdata is false, I can just say Cancel = True? Would that cancel the entire report?

Robert
 
I have never tried it that way but go ahead and try... There is no reason for it not to work!
 

Users who are viewing this thread

Back
Top Bottom