OK I'm stumped.
The variables are gettng the correct values. (I think)
But is still erroring out on the Aplication.Printers(strValue) in the Select Case.
Can someone look at this and let me know what I am missing.
The error is
Run-time error 5:
Invalid procedure call or Argument.
And the debugger points to this line.
Set Application.Printer = Application.Printers(strILDprinter)
Thanks
John Fuhrman
The variables are gettng the correct values. (I think)
But is still erroring out on the Aplication.Printers(strValue) in the Select Case.
Can someone look at this and let me know what I am missing.
Code:
Private Sub Printbtn_Click()
On Error GoTo Err_Handler
Dim strCurrentForm As String
strCurrentForm = Me.Form.Name
'Get Default Printer
Dim strDefaultPrinter As String
strDefaultPrinter = Application.Printer.DeviceName
With Me
' .SEIprint = Now()
' .Status_of_Activity = "Requested"
End With
Dim strWhere As String
' If Me.Dirty Then 'Save any edits.
' Me.Dirty = False
' End If
'Set Report Printer Variables
Dim strSEIprinter As String
Dim strILDprinter As String
'Define Report Printers
strILDprinter = "NRC ILSHR3 Dell Laser Printer 5310n"
strSEIprinter = "NRC SAVE09 HP LaserJet 8150"
MsgBox "Current Form: " & strCurrentForm & "."
Select Case UCase(strCurrentForm)
Case UCase("Add New Case"), UCase("Special Print")
[highlight]Set Application.Printer = Application.Printers(strILDprinter)[/highlight]
MsgBox "Current Form: " & strCurrentForm & "." & vbCrLf & _
"using printer " & Application.Printer.DeviceName & "."
Case UCase("UpdateActivity")
Set Application.Printer = Application.Printers(strSEIprinter)
MsgBox "Current Form: " & strCurrentForm & "." & vbCrLf & _
"using printer " & Application.Printer.DeviceName & "."
Case Else
MsgBox "Could not determine printer." & vbCrLf & _
"Using DEFAULT printer.", vbCritical + vbDefaultButton1 + vbOKOnly, _
"Printer Selection"
End Select
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "ID = " & Me.ID
DoCmd.OpenReport "CasePrint", acViewNormal, , strWhere, acWindowNormal, Me.Name
End If
'Reset the (original) default printer
Set Application.Printer = Application.Printers(strDefaultPrinter)
Err_Handler_Exit:
Exit Sub
Err_Handler:
If StandardErrors(Err) = False Then
BeepWhirl
MsgBox Err & ": " & Err.Description
End If
Resume Err_Handler_Exit
End Sub
The error is
Run-time error 5:
Invalid procedure call or Argument.
And the debugger points to this line.
Set Application.Printer = Application.Printers(strILDprinter)
Thanks
John Fuhrman