Hello!
I'm hoping for some advice and guidance but first a little bit of background on my set up:
The office has two PCs and two printers, the default printer is called "+25" and the other printer is "Zebra Printer". However the Zebra printer is also called "\\4H1Z742\Zebra Printer" because it's on a network and not hardwired to one of the PCs.
I am trying to set up two reports to print to these printers. The pallet labels report is printed on +25 and the carton labels report is on the Zebra printer. My pallet label code works fine to print from the +25 default printer but when I then attempt to run the carton label code it first prints to the +25 and then will print on the Zebra printer every time until the +25 printer is next used. I can't figure out why the carton label report wants to return to the default printer every time the pallet label report is printed. The code is supposed to set the printer to the Zebra printer but doesn't respond on the first print after printing the pallet label report.
Pallet label code
Carton label code
Any help will be much appreciated.
I'm hoping for some advice and guidance but first a little bit of background on my set up:
The office has two PCs and two printers, the default printer is called "+25" and the other printer is "Zebra Printer". However the Zebra printer is also called "\\4H1Z742\Zebra Printer" because it's on a network and not hardwired to one of the PCs.
I am trying to set up two reports to print to these printers. The pallet labels report is printed on +25 and the carton labels report is on the Zebra printer. My pallet label code works fine to print from the +25 default printer but when I then attempt to run the carton label code it first prints to the +25 and then will print on the Zebra printer every time until the +25 printer is next used. I can't figure out why the carton label report wants to return to the default printer every time the pallet label report is printed. The code is supposed to set the printer to the Zebra printer but doesn't respond on the first print after printing the pallet label report.
Pallet label code
Code:
Private Sub Command10_Click()
Dim prn As Printer
Set prn = Application.Printer
Application.Printer = Application.Printers("+25")
DoCmd.OpenReport "Rockwool_Pallet_Labels_Report_and_Subreport", acNormal
End Sub
Carton label code
Code:
Private Sub Command2_Click()
On Error GoTo ErrorHandler
Dim rpt As Report
Dim prtr As Printer
Set prtr = Application.Printer
Application.Printer = Application.Printers("\\4H1Z742\Zebra Printer")
prtr.TopMargin = 0.5
prtr.BottomMargin = 0.5
prtr.LeftMargin = 0.5
prtr.RightMargin = 0.5
prtr.PaperSize = acPRPSUser
prtr.Orientation = acPRORLandscape
'open your report in hidden view to apply print settings
DoCmd.OpenReport "Carton_Labels_Report", acViewPreview, , , acHidden
Set rpt = Reports![Carton_Labels_Report]
'Set the Printer property of the report to the
'Application.Printer object
Set rpt.Printer = prtr
' now open the report in normal view to print
DoCmd.OpenReport "Carton_Labels_Report", acViewNormal
DoCmd.Close acReport, "Carton_Labels_Report", acSaveNo
Exit Sub
ErrorHandler:
Set prtr = Application.Printer
Application.Printer = Application.Printers("Zebra Printer")
prtr.TopMargin = 0.5
prtr.BottomMargin = 0.5
prtr.LeftMargin = 0.5
prtr.RightMargin = 0.5
prtr.PaperSize = acPRPSUser
prtr.Orientation = acPRORLandscape
'open your report in hidden view to apply print settings
DoCmd.OpenReport "Carton_Labels_Report", acViewPreview, , , acHidden
Set rpt = Reports![Carton_Labels_Report]
'Set the Printer property of the report to the
'Application.Printer object
Set rpt.Printer = prtr
' now open the report in normal view to print
DoCmd.OpenReport "Carton_Labels_Report", acViewNormal
DoCmd.Close acReport, "Carton_Labels_Report", acSaveNo
End Sub
Any help will be much appreciated.