select printer

  • Thread starter Thread starter JIM.H.
  • Start date Start date
J

JIM.H.

Hello,
How can I select printer before printing report in the vb
code. I am using DoCmd.OpenReport stDocName, acNormal
in the code, before this point I need to select the
printer.
Thanks,
Jim.
 
You can save the name of the printer with the report.

While in report design mode, you can go file-Page setup.

You landscape, and even the printer you select WILL BE saved, and used for
the report.

However, often the above is not very good, since any change of computer, or
change of printers etc will make the above not valid.

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

So, to save/switch, you can use:

dim strDefaultPrinter as string

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever.

Switch back.

Set Application.Printer = Application.Printers(strDefaultPrinter)


If you are using a earlier versions, then you can use my lightweight printer
switch code here:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
 
Thanks for posting the code, Albert. I've been looking for something
like this, as I'm trying to get my application to create PDF files. It
seems to me that the best way to do it is to print the report to the PDF
printer, but I couldn't quite figure out how to do it.

grep
 
Back
Top