Adjusting print margins

D

Dale Fye

I've got a report that has a left margin of .75" and right margin of .25".

I'd like to add some code to one of the forms events, that would shift this
to left (.25") and right (.75") when a report item wraps to a second page.

Basically, what I want to do is leave room for hole punch on the left side
of most pages, but if the report extends beyond one page for a particular
item, I want the wide margin to alternate on even and odd pages (within an
item).
 
J

John Spencer

I don't think you can do that in the way your specify.

Set the Left Margin to .25 and the Right Margin to .25

You will need to move all the controls back and forth by .5 inches depending
on the page number using some VBA.

Here is a posting from Fred G that describes that. If you want to move then
items back and forth by .5 inches change 1440 to 720 (measurements are in TWIPS).
Move the left position of each control as needed for each even page, then back
for each odd page.

In the Code Window Declarations section, write:

Option Compare Database
Option Explicit
Dim MoveMargin As Integer
====
Code the Report Header Format event:

Private Sub ReportHeader_Format(Cancel As Integer, _
FormatCount As Integer)
MoveMargin = MoveMargin * -1
ChangeMargins
End Sub
=======

Code the Page Header Format event:

Private Sub PageHeader_Format(Cancel As Integer, _
FormatCount As Integer)
If Me.Page = 1 Then
MoveMargin = 0
ElseIf Me.[Page] Mod 2 = 0 Then
MoveMargin = 1440
Else
MoveMargin = -1440
End If
ChangeMargins
End Sub
=========
Add a new Sub Procedure to the code window:

Public Sub ChangeMargins()
Dim C As Control
For Each C In Me.Controls
C.Left = C.Left + MoveMargin
Next C
End Sub
====

Change the value of MoveMargin as needed.
1440 = 1 inch.
Make sure there is enough room to the right of the right-most controls to
allow for the movement towards the right.
--
Fred

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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

Similar Threads

Different margins on odd/even pages 3
Report_Close event 2
Report Margins 1
I can't change the report margins 1
Margins on my report 1
Margins 2
Why can't I change page margins? 1
Reports in Access 2

Top