M Mario Feb 16, 2009 #1 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?
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 Feb 16, 2009 #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? Click to expand... 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). --
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? Click to expand... 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 Feb 16, 2009 #3 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"
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 Feb 17, 2009 #4 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" Click to expand... --
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" Click to expand... --