changing report from printer 1 to printer 2

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?
 
M

Michael J. Strickland

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).


--
 
M

Mario

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"
 
M

Michael J. Strickland

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"



--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top