Endojoe
Registered User.
- Local time
- Today, 09:34
- Joined
- Apr 7, 2009
- Messages
- 20
I have 3 reports I want to print from a single command button. I have achieved this using the following:
I have configured each report to not print if there's no data in its corresponding Print Query using the following code in the 'On No Data' Event of each report.
All is well so long as there's actually a report in each of the 3 corresponding Print Querys. The MsgBox Error Message is only there because there are currently 3 seperate command buttons for printing. It is not critical that the user be notified in the event that any one of the 3 reports has no records to be printed. If the first or second report has no records to print, the error message prevents the rest of the code from running. So, basically, I'm looking for a way to supress or eliminate the error message from effecting the code, most likely with some kind of error handling statement between each print command...but as simple as what I've done is, I'm already in over my head. I've found this website to be immense repository of information over the last several months, and learned a great deal from it, but for this specific instance I couldn't seem to find a previously discussed simple solution.
Thank You All In Advance,
-Will-
Code:
Private Sub All_Reports_Button_Click()
On Error GoTo Err_All_Reports_Button_Click
Dim stDocName As String
stDocName = "CofC_SPU_ALL"
DoCmd.OpenReport stDocName, acNormal
stDocName = "8130_Domestic"
DoCmd.OpenReport stDocName, acNormal
stDocName = "8130_Export"
DoCmd.OpenReport stDocName, acNormal
Exit_All_Reports_Button_Click:
Exit Sub
Err_All_Reports_Button_Click:
MsgBox Err.DESCRIPTION
Resume Exit_All_Reports_Button_Click
End Sub
I have configured each report to not print if there's no data in its corresponding Print Query using the following code in the 'On No Data' Event of each report.
Code:
Option Compare Database
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There Are No Domestic 8130s Checked To Print", _
vbInformation, "You Gone And Screwed Up Now..."
Cancel = True
End Sub
All is well so long as there's actually a report in each of the 3 corresponding Print Querys. The MsgBox Error Message is only there because there are currently 3 seperate command buttons for printing. It is not critical that the user be notified in the event that any one of the 3 reports has no records to be printed. If the first or second report has no records to print, the error message prevents the rest of the code from running. So, basically, I'm looking for a way to supress or eliminate the error message from effecting the code, most likely with some kind of error handling statement between each print command...but as simple as what I've done is, I'm already in over my head. I've found this website to be immense repository of information over the last several months, and learned a great deal from it, but for this specific instance I couldn't seem to find a previously discussed simple solution.
Thank You All In Advance,
-Will-