Article ID: 129722
Article Last Modified on 7/5/2002
Option Explicit
Sub ChgRptOrient (ReportName As String)
' The zwtDevModeStr and zwtDeviceMode types are defined in the
' zwAllGlobals module in the WZFRMRPT.MDA file.
Dim DevString As zwtDevModeStr
Dim dm As zwtDeviceMode
'Constant for the Fields member.
Const DM_ORIENTATION = &H1
Dim stDevModeExtra As String
Dim rpt As Report
Dim msg As String
'Open the report in Design view.
DoCmd OpenReport ReportName, A_DESIGN
Set rpt = Reports(ReportName)
If Not IsNull(rpt.PrtDevMode) Then
'Copy the PrtDevMode property to a string.
stDevModeExtra = rpt.PrtDevMode
DevString.rgb = stDevModeExtra
LSet dm = DevString
'Display the current orientation.
msg = "The Orientation is currently"
If dm.dmOrientation = 1 Then
msg = msg & " Portrait. Change to Landscape?"
Else
msg = msg & " Landscape. Change to Portrait?"
End If
response = MsgBox(msg, 4)
If response = 6 Then
'User chose Yes.
'Initialize the Fields member.
dm.dmFields = dm.dmFields Or DM_ORIENTATION
'Set the orientation.
If dm.dmOrientation = 1 Then
'Set the orientation to Landscape.
dm.dmOrientation = 2
Else
'Set the orientation to Portrait.
dm.dmOrientation = 1
End If
'Update the first 68 bytes of the PrtDevMode property.
LSet DevString = dm
Mid$(stDevModeExtra, 1, 68) = DevString.rgb
rpt.PrtDevMode = stDevModeExtra
End If
End If
End Sub
Keywords: kbinfo kbprint KB129722