Different margins on odd/even pages

R

rpfiegener

Hello - Anyone have code or tricks to format an Access report for
binding?

For example, with 1" margin on left and 0.5" margin on right for odd
pages,
and 0.5" margin on left and 1" margin on right for even pages.

Works in most other Office apps, but not Access?

Many thanks,
rpf
 
A

Allen Browne

One way to do this is to set half inch margins, and move the controls across
the page in the Format even of the Page Header section.

This example assumes you put the unmoved position of each control you want
to move into its Tag property. The value should be in twips, where 1440
twips = 1 inch. For example, if a control is 2" from the left margin (not
allowing for the half inch gutter), you put 2880 into its Tag property.

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim ctl As Control
Dim iGutter As Integer

'Use half an inch gutter on the even pages.
If (Me.Page Mod 2) = 0 Then
iGutter = 720
End If

For Each ctl In Me.Controls
If IsNumeric(ctl.Tag) Then
ctl.Left = CInt(ctl.Tag) + iGutter
End If
Next
End Sub
 
J

John Spencer

Here is an alternative from an old posting of FredG (I believe)

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
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
F

fredg

Here is an alternative from an old posting of FredG (I believe)

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.

I'm glad you said 'from an old posting of FredG ....'
and not
from a posting of old FredG .... <g>
 

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

Top