Using Access 2000
A form has an option group, called "fraReports" with 9 options, also a Print command button.
Behind the Print button there is Select Case and DoCmd code which prints a report that matches the option value selected.
I want to set up a command button that will "Print All" of the reports with one click. I can do that with the following code behind the cmdPrintAll button.
This works...but is there a simpler way to set this up, or is the code I am using as good a method as any?
Thanks.
Tom
A form has an option group, called "fraReports" with 9 options, also a Print command button.
Behind the Print button there is Select Case and DoCmd code which prints a report that matches the option value selected.
I want to set up a command button that will "Print All" of the reports with one click. I can do that with the following code behind the cmdPrintAll button.
Code:
Private Sub cmdPrintAll_Click()
Select Case MsgBox("Are you sure you wish to print ALL reports in the packet?", vbYesNo Or vbExclamation Or vbDefaultButton1, "Print ALL check")
Case vbYes
GoTo PrintAllRoutine
Case vbNo
Exit Sub
End Select
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocName3 As String
Dim stDocName4 As String
Dim stDocName5 As String
Dim stDocName6 As String
Dim stDocName7 As String
Dim stDocName8 As String
Dim stDocName9 As String
Dim parm As String
On Error GoTo cmdPrintAll_Click_Error
PrintAllRoutine:
parm = "[tblPatInfo].[VISIT ID]='" & Forms!frmPatInfo![VisitID] & "'"
stDocName1 = "rptV1"
stDocName2 = "rptV2"
stDocName3 = "rptV3"
stDocName4 = "rptV4"
stDocName5 = "rptV5"
stDocName6 = "rptV6"
stDocName7 = "rptV7"
stDocName8 = "rptV8"
stDocName9 = "rptV9"
DoCmd.OpenReport stDocName1, acViewNormal, , parm
DoCmd.OpenReport stDocName2, acViewNormal, , parm
DoCmd.OpenReport stDocName3, acViewNormal, , parm
DoCmd.OpenReport stDocName4, acViewNormal, , parm
DoCmd.OpenReport stDocName5, acViewNormal, , parm
DoCmd.OpenReport stDocName6, acViewNormal, , parm
DoCmd.OpenReport stDocName7, acViewNormal, , parm
DoCmd.OpenReport stDocName8, acViewNormal, , parm
DoCmd.OpenReport stDocName9, acViewNormal, , parm
On Error GoTo 0
Exit Sub
cmdPrintAll_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdPrintAll_Click of VBA Document Form_frmBloodTransfusion"
End Sub
This works...but is there a simpler way to set this up, or is the code I am using as good a method as any?
Thanks.
Tom