Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Orientation when Printing report not previewing

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
I have a reports menu that allows you to print preview and/or print direct to the printer. I can successfully change printers but have not been able to change the orientation before the report prints. It works fine in print preview because you see the report first but doesn't when you take the default and not open the report. Does anyone know how to get around this? My code is:


'remember the default printer
If isBlank(Me!cmbPrinter.Value) Then
Me!cmbPrinter.Value = Application.Printer.DeviceName
End If

'grab the printer object for the selected report

Set Prt = Application.Printers(Me!cmbPrinter.Value)

'read user-specified settings

Prt.PaperSize = Me!cmbPapersize
Prt.DefaultSize = True
Prt.Orientation = Me!OpgOrientation

WhichReport (Me!lbxSelectReport.Value)
'added this line because it didn't seem to pick up the prt.orientation
Printer.Orientation = Me!OpgOrientation

DoCmd.OpenReport StDocName

The report works and goes to the printer direct but doesn't not switch orientations if I switch them on the menu.
Which report is a function that passes the report name
Thanks
Lhuffst
 
Access 2002 & later supports a better version of the printer object which exposes orientation. Changes can be made when the report is opened in design view (which you can do in code). If you are using this version, just do a help search on the Printer Object. Sorry can't post code now as I am leaving, but will check back tomorrow.
Good Luck!

It's always darkest before dawn. So if you're going to steal your
neighbor's newspaper, that's the time to do it.
 
genomon -- Your right, it does work fine if you open it in design view (preview) but for this app. I need one that opens it in print preview and one that doesn't. The one that I'm having problems with is the report that isn't opened in preview. I also rechecked and it doesn't take the different printers either. Any ideas?
Lhuffst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top