How to get a report to default to a default printer...

T

ThriftyFinanceGirl

Keeps saying "previously formatted for..." and asking for another printer
that is not available, additionally, once we "redirect" it to an available
printer, it will print THAT TIME, but will default back to the unavailable
printer everytime it is opened. I didn't do anything in the code to set the
printer so I'm a little baffled by this.

Is there something that I CAN do in the code to keep the formatting as it
should be?
Example: Landscape, Legal paper and NOT to a specific printer?
 
J

Jack Leach

You can modify the report's printer and properties through code (in 2002 and
later, version before 2002 didn't have the Printer object and rely on the
much more complicated DevMode APIs). Unfortunately, you cannot modify the
printer in any of the report's events, so you need to open the report in
preview, set the printer, then PrintOut...


(aircode)
Sub PrintRpt(sReportname As String)

DoCmd.OpenReport sReportname, acViewPreview

With Reports(sReportname).Printer
.DeviceName = "HP Deskjet 2200L"
.Orientation = acPrOrLandscape
.etc etc
End With

DoCmd.PrintOut....

DoCmd.Close acReport, sReportName, acSaveNo

End Sub




If you manually open the report in design mode, change the printer settings,
and save the report, the new settings should be retained, though I'm not sure
you can do this and leave the report's printer blank (in fact, I believe that
the report's printer, if blank, defaults to Application.Printer, which is the
default printer as set in Control Panel).


I've had quite a time myself lately going through the trouble to set up a
global handler (which ended up turning into my first Class module) to handle
such scenarios as these. As far as I can come up with, the only way to
handle printers and have everything go the way you want is to do it
programmatically as above.

hth, gl!


--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
S

Stuart McCall

ThriftyFinanceGirl said:
Keeps saying "previously formatted for..." and asking for another printer
that is not available, additionally, once we "redirect" it to an available
printer, it will print THAT TIME, but will default back to the unavailable
printer everytime it is opened. I didn't do anything in the code to set
the
printer so I'm a little baffled by this.

Is there something that I CAN do in the code to keep the formatting as it
should be?
Example: Landscape, Legal paper and NOT to a specific printer?

Here's what I do. First go through all your reports in design view and for
each one, go to File | Page Setup and set the report to print to the default
Windows printer.

Then I use the code here:

http://www.smccall.demon.co.uk/Reports.htm#SetDevice

to switch the default printer to the required one before printing the
report.
 
J

Jim Evans

You might try going into the report design mode and setting the printer
(under the File menu) to the "default" printer. I had a problem like you
describe several years ago and this fixed my problem.

Good luck!

Jim
 

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