set a printer thru a form?

  • Thread starter Thread starter Rover
  • Start date Start date
R

Rover

I want to set the printer for the report I run from a form. That is to
say, I always want to print on the same printer no matter what the
default printer is set to.

Jim
 
If you open a report in design mode, and then go file->page setup.

Any, and all settings you place in those settings (things like landscape,
and printer selected) will be saved.

So, in the page "tab" of the above...you can select, and save a specified
printer.

If your applciaton is used on more then one pc, or in a multi-user
envirment, then you might not need the aobve...and I can post you some code
soltions to switch the printer if you need.
 
I guess I should have indicated that I am running it multi-user
environment. I would appreciate the code.

Thanks in advance.

Jim
 
Hi Jim:

Since you can't change a form into design mode while using the runtime
environment, you have to temporarily change your default printer through
code, changing the Windows API, then change it back. It's pretty complicated
when using MS Access 2000 and older; I understand that with Access XP this
issue was improved. You can find the code in Getz's book "MS Access
Handbook".

Regards,
Al
 
I guess I should have indicated that I am running it multi-user
environment. I would appreciate the code.

Note that access XP does have built in the ability to switch printers. So,
while my code *should* work, you do NOT need it in a2002.

You can use:

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

The above means you don't need my code.

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 version of ms-access, then I have a short and
simple printer switch routine here that does NOT requite you to flip the
report into design mode:

You can find this short piece of code here:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
 
Back
Top