OnClick to Print Multiple Reports

kaveman

Registered User.
Local time
Today, 02:29
Joined
May 12, 2004
Messages
58
Hello,

I have a button on a form that I am using to print multiple reports at one time, each report is used to summarize department invoices for a specified date range. Here is the code I am using to print the reports:

Private Sub cmdFK_Click()
On Error GoTo Err_cmdFK_Click

Dim stDocName As String

stDocName = "Invoice_Dept001_sub"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Invoice_Dept002_sub"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Invoice_Dept003_sub"
DoCmd.OpenReport stDocName, acNormal


Exit_cmdFK_Click:
Exit Sub

Err_cmdFK_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdFK_Click

End Sub

My issue occurs when one of the reports has no data. For instance if the report 'Invoice_Dept002_sub' has no data an error message pops up and terminates the entire process.

Is there some changes I can make to this code where if one of the reports has no data that report is skipped and the process moves on to printing the next report?
 
Put this in the reports On No Data event...

Code:
Private Sub Report_NoData(cancel As Integer)
On Error GoTo Err_Report_NoData

    'MsgBox "Your report request has no data to print." & "  Your print request has been canceled." & "  Ensure you have selected the correct criteria.", vbInformation + vbOKOnly, "No Data To Print - rprDuplicateRACFs"
    
    Cancel = True

Exit_Report_NoData:
    Exit Sub

Err_Report_NoData:
    MsgBox Err.Number & " - " & Err.Description, vbCritical, "Report_NoData()"
    Resume Exit_Report_NoData

End Sub
 
Actually the 2501 error has to be handled, not in the NO DATA event, but in the event that opened the report.
 

Users who are viewing this thread

Back
Top Bottom