Set to landscape on printing from command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can i set my command button print in landsape as i dont want to set the
printer defaults to landscape as other printouts are in portrait format.
 
Matt said:
Can i set my command button print in landsape as i dont want to set the
printer defaults to landscape as other printouts are in portrait format.

Search in the help files for the PrtDevMode property. Here's some code from
earlier version helpfiles that does what you want:

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
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Matt said:
Can i set my command button print in landsape as i dont want to set the
printer defaults to landscape as other printouts are in portrait format.

Why not just set those reports that need landscape as landscape? ms-access
will remember this setting. Thus, no code is needed...
 

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

Back
Top