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

Change report orientation through Access VBA

Status
Not open for further replies.

Tadynn

Technical User
Oct 8, 2001
72
AU
Hi all,

Using access 2K

This I assume is a fairly simple one (except for me that is).

My report that I run, ocassionally resets the page setup values that I have assigned it through page setup. I thought that a good way to fix this would be to assign the page setup values through code as part of the report_Open sub.
The problem I'm having is that when I add the line "Me.Report.Orientation = 1" and attempt to run the report. I get a runtime error advising that I can't assign a value to the object (2448). Here is my code:

Private Sub Report_Open(Cancel As Integer)
Report.Orientation = 1
End Sub

Maybe my thinking is wrong, but I assumed that 1 = landscape, and 0 = portrait. Because I stepped through the code and use the intermediate window to get the value of Report.Orientation, and got "Report.Orientation = 0" (I set the report to portrait through page setup on purpose to make sure that my code works). Maybe I'm using the wrong piece of code here for what I want to achieve?


Just to take this further, how would I set the margins to the following through code:

Top = 20mm
Bottom = 20mm
Left = 20mm
Right = 20mm

Thanks in advance,

Tadynn





















 
The Report.Orientation property stand for Left-to-right or Right-to-left writing.
For paper orientation and marges setting, take a look here: thread702-560490

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Tadynn,

you have to open the report in the designview to change it's page-settings. e.g. with the on click event of a button on a form:

'Code************************************************
Private Sub btn_OpenReport_Click()
DoCmd.OpenReport "yourreportname", acViewDesign, , , acHidden


Reports!yourreportname.Orientation = 1
DoCmd.Close acReport, "yourreportname", acSaveYes

DoCmd.OpenReport "yourreportname", acViewPreview

End Sub
'code end ********************************************

To set the margins of the page search for "PrtMip Property" in MS Access or VBA built in help. (At least in Acces 2002 you find very useful codesamples how to do this).


HTH,
fly

Martin Serra Jr.
 
Sorry!!

Of course PHV is right.

The only thing correct in my previous post was, that you have to open the report in design view, before you can change it's page settings.

Sorry again.
fly

Martin Serra Jr.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top