Setting Specific Printer via VBA

ions

Access User
Local time
Today, 04:47
Joined
May 23, 2004
Messages
816
Dear MS Access Expert.

Suppose I have report X that is set to Printer Z ( or a default printer for that matter)

How can I change the Specific Printer for Report X from Printer Z to Printer A via VBA?

Thank you very much.
 
First, you have to open the Report in Design view. You can browse the Application.Printers collection until you find the one you want by looking at DeviceName. Let's say the one you want is Application.Printers(5). Change the report printer by doing:

Set Reports!MyReport.Printer = Application.Printers(5)

John Viescas, author
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
 
Will this work if your printers are hook up on network?
 
Yes, as long as the printer is defined on the machine.

John Viescas, author
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
 
Thanks for the quick reply. We are having a problem printing one of our forms. I can print the form if I manually select the printer. If I close the form and return to the form I cannot print the document. If I keep the form open I have no problem printing the document. Strange
 
Yes no problem, as long to enter the correct name.
 
Why are you printing a form? That's not normally a good idea. Better to design a report.


John Viescas, author
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
 

Users who are viewing this thread

Back
Top Bottom