I have two forms. The first one displays a record and the second one is a 'print page'. On this second form I have five option buttons and another command button at the bottom. I want the user to select which option they want, and click on the command button 'Print', to print whatever selection they've choosen. (I don't need to have the report previewed, I just need it to print!) Here are the option buttons:
1- Print Clearance Sheet
2- Print Tag Sheet
3- Print Tags
4- Print all the above
5- Print Clearance and Tag Sheet
I have played around with this, and came up with the following code to be placed in the OnClick of the command button:
Private Sub print_button_Click()
On Error GoTo Err_print_button_Click
Dim stDocName As String
stDocName1 = "Clearance Report"
stDocName2 = "Tag (Summary) Print off"
stDocName3 = "Clearance Tag Print"
If OptionButton.Value = 1 Then
DoCmd.OpenReport stDocName1, acNormal
ElseIf OptionButton.Value = 2 Then
DoCmd.OpenReport stDocName2, acNormal
ElseIf OptionButton.Value = 3 Then
DoCmd.OpenReport stDocName3, acNormal
ElseIf OptionButton.Value = 4 Then
DoCmd.OpenReport stDocName1, acNormal
DoCmd.OpenReport stDocName2, acNormal
DoCmd.OpenReport stDocName3, acNormal
ElseIf OptionButton.Value = 5 Then
DoCmd.OpenReport stDocName1, acNormal
DoCmd.OpenReport stDocName2, acNormal
End If
Exit_print_button_Click:
Exit Sub
Err_print_button_Click:
MsgBox Err.Description
Resume Exit_print_button_Click
End Sub
The only problem with this, is that when I click on the button it gives me a "object required" notification.... and for the life of me I can't figure out what is wrong. Does anyone have any suggestions?
1- Print Clearance Sheet
2- Print Tag Sheet
3- Print Tags
4- Print all the above
5- Print Clearance and Tag Sheet
I have played around with this, and came up with the following code to be placed in the OnClick of the command button:
Private Sub print_button_Click()
On Error GoTo Err_print_button_Click
Dim stDocName As String
stDocName1 = "Clearance Report"
stDocName2 = "Tag (Summary) Print off"
stDocName3 = "Clearance Tag Print"
If OptionButton.Value = 1 Then
DoCmd.OpenReport stDocName1, acNormal
ElseIf OptionButton.Value = 2 Then
DoCmd.OpenReport stDocName2, acNormal
ElseIf OptionButton.Value = 3 Then
DoCmd.OpenReport stDocName3, acNormal
ElseIf OptionButton.Value = 4 Then
DoCmd.OpenReport stDocName1, acNormal
DoCmd.OpenReport stDocName2, acNormal
DoCmd.OpenReport stDocName3, acNormal
ElseIf OptionButton.Value = 5 Then
DoCmd.OpenReport stDocName1, acNormal
DoCmd.OpenReport stDocName2, acNormal
End If
Exit_print_button_Click:
Exit Sub
Err_print_button_Click:
MsgBox Err.Description
Resume Exit_print_button_Click
End Sub
The only problem with this, is that when I click on the button it gives me a "object required" notification.... and for the life of me I can't figure out what is wrong. Does anyone have any suggestions?