Setting Specific Printer via VBA (1 Viewer)

ions

Access User
Local time
Today, 13:19
Joined
May 23, 2004
Messages
739
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.
 

JPaulo

Developer
Local time
Today, 21:19
Joined
Dec 21, 2009
Messages
185
Hi;

See this example in attc.
 

Attachments

  • Printers.zip
    25.7 KB · Views: 3,344

TexanInParis

Registered User.
Local time
Today, 22:19
Joined
Sep 9, 2009
Messages
109
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)
 

Joe8915

Registered User.
Local time
Today, 14:19
Joined
Sep 9, 2002
Messages
821
Will this work if your printers are hook up on network?
 

TexanInParis

Registered User.
Local time
Today, 22:19
Joined
Sep 9, 2009
Messages
109
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)
 

Joe8915

Registered User.
Local time
Today, 14:19
Joined
Sep 9, 2002
Messages
821
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
 

JPaulo

Developer
Local time
Today, 21:19
Joined
Dec 21, 2009
Messages
185
Yes no problem, as long to enter the correct name.
 

TexanInParis

Registered User.
Local time
Today, 22:19
Joined
Sep 9, 2009
Messages
109
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

Top Bottom