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!

Changing Orientation of Report

Status
Not open for further replies.

Dina01

Programmer
Mar 26, 2002
204
CA
Hello ,

I have a db that has a form and when I choose the View or Print Option and then I click on the PrintButton.

It will print out my report, but I want this report to Print or be viewd in Landscape.....


This is the code I have in my form to print the report..

*******************************************
Private Sub PrintButton_Click()
Dim WClause
Const RName = "rptTrackAgent"
WClause = "[Date] Between #" & _
Me![Start] & "# AND #" & _
Me![End] & "# AND [Agent] = '" & _
Me![Agent] & "'"

If DCount("*", "qryAgentTracking", WClause) Then
DoCmd.OpenReport _
Reportname:=RName, _
WhereCondition:=WClause, _
View:=Me![OutputTo], _
Orientation:=acPRORLandscape

Else
MsgBox "No Matching Records"
End If
End Sub

But My program bugs everytime at the Orientation:=acPRORLandscape


Does anyone one know how to do this in VB Code...
 
Will it always be viewed or printed in landscape?? If so, couldn't you change the design to landscape?? If not, here is some code from Access help:

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.
[/code]
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
[/code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top