Page Orientation

J

Jen

Hi,

I have a main report that consists of 6 sub reports. I have found a way to
combine them, but the problem is that while most are in portrait, some need
to print in landscape. Is there a way to code the report or the specific
subreport to change orientation for those pages to landscape & then have it
change back?

Thought I'd try...
 
E

Evi

I've never tried this but Acc97 has the following in its Help:

The PrtDevMode property setting is a 94-byte structure that mirrors the
DEVMODE structure defined in the Win32 Software Development Kit. For
complete information on the PrtDevMode property members, consult the Win32
Software Development Kit.

The following example shows how to change the orientation of the report.
This example will switch the orientation from portrait to landscape or
landscape to portrait depending on the report's current orientation.



Sub SwitchOrient(strName As String)

Const DM_PORTRAIT = 1

Const DM_LANDSCAPE = 2

Dim DevString As str_DEVMODE

Dim DM As type_DEVMODE

Dim strDevModeExtra As String

Dim rpt As Report

DoCmd.OpenReport strName, acDesign
' Opens report in Design view.

Set rpt = Reports(strName)

If Not IsNull(rpt.PrtDevMode) Then

strDevModeExtra = rpt.PrtDevMode

DevString.RGB = strDevModeExtra

LSet DM = DevString

DM.lngFields = DM.lngFields Or DM.intOrientation
' Initialize fields.



If DM.intOrientation = DM_PORTRAIT Then

DM.intOrientation = DM_LANDSCAPE

Else

DM.intOrientation = DM_PORTRAIT

End If

LSet DevString = DM
' Update property.

Mid(strDevModeExtra, 1, 94) = DevString.RGB

rpt.PrtDevMode = strDevModeExtra

End If

End Sub


Evi
 
J

Jen

Do you know where I would put the code? Would this be triggered by an event
on the main report?

Thank you!
 
E

Evi

This code is just a pointer. As I say, I've never tried it myself . In this
code it is actually takes place when the report is opened (DoCmd.OpenReport)
perhaps from a command button so that line will have to be taken out.

The code as it is toggles the report so that it changes its orientation
from what it currently is, to the other orientation but I don't know,
without experimenting, if this can be done once the report is actually open.
The code doesn't to spot when it needs to change, so if it can change
during the printing process, it would only be if you have something that
happens eg a particular record is reached or a particular section is
printing.

If this doesn't do it, and no-one has any better suggestions then you may be
stuck with either having to print it all in landscape or having to have more
than 1 report, which does seem a shame after all that effort.

Evi
 

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