Automatically Print report to specific printer but did not set it back to the default print
Posted on 2012-03-12
I was just too quick to close my last question before I notice this problem. (My last question was "Automatically Print Report to a specific Printer") and Helen Feddema and Dodahd gave me the answer which works to print to the specific print but I notice that after I print this specific report to the specific printer, and tried to print other report, it seems the system did not reset the second report that I tried to print back to my default printer. Below is all the code that I'm using in the program:
In the Module is :
Public Sub PrintToSpecificPrinter(strPrinter As String, strReport As String)
'Created by Helen Feddema 12-Feb-2010
'Last modified by Helen Feddema 12-Feb-2010
On Error GoTo ErrorHandler
Dim prtCurrent As Printer
Dim prtDefault As Printer
'Dim strPrinter As String
'Save current default printer
Set prtDefault = Application.Printer
Debug.Print "Current default printer: " & prtDefault.DeviceName
'Select a specific printer as new default printer
Application.Printer = Printers(strPrinter)
'Print the report
'Set printer back to former default printer
Application.Printer = prtDefault
MsgBox "Error No: " & Err.Number & "; Description: " & _
In my OnClick Event is :
Private Sub Command18_Click()
On Error GoTo Err_Command18_Click
Dim stdocname As String
Dim stCriteria As String
Dim strReport As String
Dim strPrinter As String
strPrinter = strdocname
strPrinter = "AA_ABCE_CL4650_122"
Form_frmPrintedFormsAll.HoldAnyData = Me.NameEntered
Form_frmPrintedFormsAll.Note = Me.AddNote
Form_frmPrintedFormsAll.RecordNo = Me.RecordNo
If IsNull(NameEntered) Or IsNull(RecordNo) Then
MsgBox "Please enter all informations before proceeding."
stCriteria = "CHRecord = '" & Me.RecordNo & "'"
strReport = "rptFileRequest"
Call PrintToSpecificPrinter(strPrinter, strReport)
DoCmd.Close acForm, "frmParmFileRequest"
My default printer is "AA_ACEE_CL4530_135" but it prints everythig to printer "AA_ABCE_CL4650_122" after I print that specific report. Can any one help?