If i cancel the printout at
any point, it does not go back to default printer. How can i fix this?
Do you have error trapping? I mean, if the report is cancelled, that
has little to do with running some code to set the default printer.
Obviously, your will need to run code to set the printer back the default.
I would have to think that if your code that sets the default printer is
simply not being run.
You don't mention what version of ms-access, but for a2002 and later,
there is a built in printer object...so, you would not need my code
eg:
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")
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. --- print reports...etc...
Switch back.
Set Application.Printer = Application.Printers(strDefaultPrinter)