changing report from printer 1 to printer 2

  • Thread starter Thread starter Mario
  • Start date Start date
M

Mario

How can I change through code if the report is set up to print to printer 1,
and I want it to print to printer 2?
 
Mario said:
How can I change through code if the report is set up to print to
printer 1,
and I want it to print to printer 2?



Public rpt As Report
Set rpt.Printer = Printers("Printer Name")

where "Printer Name" is the name of the printer you want to use
(the exact name from Settings->Printers in Windows).


--
 
I entered this code in the on click property of a form and got this message
after it highlighted the word "Public":

"Invalid Attribute in Sub or Function"
 
Try the following in the click event of a button on your form or in your
form's load event:

Dim rpt As New Report
Dim strReportName As String
Dim strPrinterName As String

* strReportName = [name of your Report here]
* strPrinterName = [name of your Printer here]

DoCmd.OpenReport strReportName, acViewDesign

Set rpt = Reports(strReportName)
rpt.Visible = False

Set rpt.Printer = Printers(strPrinterName)

DoCmd.Close acReport, strReportName, acSaveYes

*[ ] enclose name of report/printer here (in quotes).



Mario said:
I entered this code in the on click property of a form and got this
message
after it highlighted the word "Public":

"Invalid Attribute in Sub or Function"



--
 
Back
Top