Automatically printing to printer other than default

D

David Findlay

I can get my vba to print my report to the default printer, but is there
a way I can have it print to a different printer automatically like
that? I have a normal laser printer and a label printer. When you click
print label in my form I'd like it to automatically print on the label
printer, and have it automatically print on the laser(which is default
on the system) for everything else. Any way to do this? Thanks,

David
 
K

Ken Snell [MVP]

If you're using ACCESS 2002 or 2003, check out Application.Printer in Help
file. It allows you to set the printer to a printer device that is installed
on the PC.
 
A

Allen Browne

Open the report in design view.
Choose Page Setup from the File menu.
Specify a particular printer there.
Access will remember to send the report to that printer.

If you are developing for others and need the user to be able to select one
of their printers (which may not be installed on your development machine),
you can create a custom property on the report document to store the user's
preferred printer. Details:
Printer Selection Utility
at:
http://allenbrowne.com/AppPrintMgt.html
 
D

David C. Holley

Ooo! Ooo! Mr. Kotter! Mr. Kotter!

I've been playing with the idea of using code to select a different
printer from the default printer for a specific report. One option that
I've thought about would be a table that designates which printer should
be used for with report. The table would appear as...

txtPrinterName txtReportName

You'll need to use the PRINTERS collection of the APPLICATION object to
get the exact names of the printers. From there put the exact name into
the table along with the name of the Report. Then before you call the
report, capture the default printer as in Application.Printer. Change
the default printer using

Application.Printer = DLookup()

Then printer the report. Then right after the OpenReport statement
change the default printer back to the what it was. (Capture
Application.Printer to a variable)

I have *NOT* done this myself, its just an idea that I've been playing
with. The problem that you may encounter is if you're deploying the FE
across multiple PC's - the printers may not be named the same. However,
I've been playing with another solution that will give the user the
option of selecting a different printer if the designated printer isn't
found.

David H
 
K

Ken Snell [MVP]

I use this exact concept in one of my applications. I have a local table in
the frontend where the user can assign printers to various "report types"
(e.g., fax, invoice, receipt, statement, etc.). The user is able to assign a
printer device to each via a form with combo boxes.

Then, in the various forms, before I print the report, I run code that looks
up the assigned printer device name, sets the Application.Printer object to
that device, prints the report, and then sets Application.Printer back to
Nothing (returns the printer to the default).

This allows each user to have his/her own choices of printers on the PC. Not
bad once you write the subroutines to easily do the lookup and assigning.
 
D

David C. Holley

But of course.
The other thing which I started playing with but haven't had time to
perfect was a TreeView of the Default Printer and other available
printers where you could drag & drop a printer & have it designated as
the printer for the report. That's stalled out since I don't have time
to perfect it and having to delve into the wonderful world of Drag &
Drop. Which I'm having problems understanding.
 
D

David C. Holley

Of course, I'm now liking the idea of a custom version of OpenReport
that takes all of the parameters of DoCmd.OpenReport (maybe 1 or two
more) and handles changing the DefaultPrinter. Too bad VBA doesn't
feature method overloading (if that's the term for it - been awhile
since I took a class in Java). DARN! DARN! DARN!

David H
 

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