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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change print orientation and more by code

Status
Not open for further replies.

fmientjes

Programmer
Mar 27, 2002
55
NL
I am looking for code that assigns the right printing orientation and f.i. margins for a specified reports.
I am trying to use the following code for setting the orientation:

Sub setOrientation(r As Report, orientation As Integer)
'
' Changes the orientation of a report that is opened in DESIGN mode
'
Dim dm As str_DEVMODE
Dim DevMode As type_DEVMODE

DoCmd.OpenReport r, acDesign

If Not IsNull(r.PrtDevMode) Then
dm.RGB = r.PrtDevMode
LSet DevMode = dm
DevMode.orientation = orientation
LSet dm = DevMode
r.PrtDevMode = dm.RGB
End If
End Sub

Executing call setOrientation(Rpt_xx,0) gives an error message;"ByRef argument types do not match"
I must say that I don't understand exactly what this code does.

Can somenone help me with the right code and maybe some general information over how to control output by VBA?

Thanks,
Frans
 
Frans, why are you changing the page orientation at DESIGN view? Does not setting the page orientation IN design mode, and then SAVING the design retain that orientation when you print?

You've lost me here.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Jim,

You remark makes sense. Unfortunately Access not always keeps the printer settings (sometimes another persons login changes it, due to other default printers f.i.). It's also not a property from the report (at least I can't find it).
That's why I want some code to surely set the right settings before printing.
Can you help me out?

Frans
 
Hmmm.. I haven't run in to this before, are you saying that two different people who log in at the same machine have two DIFFERENT printers set up as their userid's DEFAULT printer? That sounds like it could be a pain in the butt....

I just can't see how page orientation (portrait to landscape) should change just because "I am using that HP/5" and "You are using that Lexmark" and "She is using that Epson FX80" or vice versa.

The reports are defined to use "default" printer, right, not "specific printer" ???

Does altering that setting make any difference?

I'm probably not gonna be much help here, I've not run across this problem before.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top