How to change the printer for a report

S

Shadow

Any kind of help/advice is much appreciated.

Is it possible to change the printer of a report from VBA?

Different users from different machines access a database on a local
network. Most of reports use the default printer. In special cases I have to
change the printer when a user clicks a button on a form to print a report.
To be more clear, I need to print a report from printer A and in special
occations from printer B. Is there any way to change the printer of a report
by VBA?
 
A

Alex White MCDBA MCSE

The simple way I have solved this for some of my projects is this:-

the client has two printers

a report call rpt_test

within the access database I have copied the report to a new report name so
2 copies of the same report exist, then I change the printer settings of one
of the reports and save it, then if rpt_test is called it goes to one
printer and if the other report is called it goes to the other printer,
there maybe other ways of doing this but this method requires no extra code
to switch printers and maybe just an extra print button to say print the
other report.
 
S

Shadow

thank you for your quick reply.
At present I'm using this system, but considering the No. of machines and
local printers and network printers, the No. of reports are growing (24
reports up to now). I've been asked to add 3 more reports. Since I need to
print these reports from different machines and different shared printers I
have to create at least 8 more reports. It would be great if there's a way
to change the printer when calling a report.

Ghalamkari
 
D

Douglas J Steele

From a previous post from Albert Kallal:

You don't mention what version of ms-access.

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(strDefaul­tPrinter)


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

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
 
A

Alex White MCDBA MCSE

Hi Doug,

You have found a reason for me to move from Access 2000

Thank you.
 
B

Bob Howard

Sorry --- the first one. I had to poke around for a while, but got something
that works from Windows 98 all the way up through XP. But I started with
the article by Getz and Litwin. The code I use has a form with a little VBA
behind it, plus 5 VBA modules containing the guts of the thing. The form
lets the user change the default printer setting from a drop down list. It
leaves the default changed (caused a problem last week because I forgot to
change it back and my wife had "printing problems"). I'll be happy to email
it to you if you like --- but you would probably want to change the form
since I run mine as Popups. Bob.
 
B

Bob Howard

On checking a second time, both of the links provided eventually point you
to the Getz/Litwin article ... so it made no difference. Again, let me know
if you want the code (the download link on their site doesn't work for me).
 
S

Shadow

Sorry for not mentioning the version of Ms-Access.
I'm running on Access 2003.

this solution seems to be the easiest one in all the suggested ways.
I appreciate your help.
 
A

Albert D.Kallal

You don't mention what version of ms-access.

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. (docmd.OpenReprot).....

Swtich back.

Set Application.Printer = Application.Printers(strDefaultPrinter)


If you are using a earlier versions, then you can use my lightweight printer
switch code here, as it is quite short, and allows coding as above:

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
 

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