Mirror Margins for Access Report?

J

jfalberg

I have setup a report in access that needs to have an inside margin of .5"
and an outside margin of .3125", but when I go to page setup and margins, I
don't see the mirror margins option.

Is there any way I can programmically setup based on an "OnPage" event or
something where it can adjust the left & right margins on odd/even pages?
 
A

Allen Browne

Yes: you can set 0.3" margins on both sides, and then adjust the Left
property of each control by 0.2" programmatically in the Format event of the
Page Header, depending on whether the Page is odd or even.

In the report's Open event, save the Left property of each control into an
array, so you know it's home position. In the pager header's format event,
you can determine whether the page is even or odd with the Mod operator
(remainder after dividing by 2.) This assumes the Page number is not being
programmatically reset.

The offset (gutter width) should be in twips, where 1440 twips = 1 inch.

Be sure to leave the 0.2" blank space to the right of the page, or the
controls won't be able to move over.

You may be able to jag it by pasting this into the report's module:

-------------code starts------------------
Option Compare Database
Option Explicit

Private Const mlngcOffset = 288& 'Offset in twips
Private malngHomePos() As Long 'Array: Left property of each control.

Private Sub Report_Open(Cancel As Integer)
Dim i As Long

ReDim malngHomePos(Me.Controls.Count - 1&)
For i = 0& To Me.Controls.Count - 1&
malngHomePos(i) = Me.Controls(i).Left
Next
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim i As Long
Dim bIsEven As Boolean

bIsEven = (Me.Page Mod 2 = 0)
For i = 0& To Me.Controls.Count - 1&
Me.Controls(i).Left = malngHomePos(i) + IIf(bIsEven, mlngcOffset,
0&)
Next
End Sub
-------------code ends------------------
 
J

jfalberg

I added the code below, but am getting a debug error when I try to get to
page 2. In debugger, I see malngHomePos(1) set to 3773. By having the
report with subreports, could that be why?

Error message: Run-time error '2100': The control or subform control is
too large for this location.
 
A

Allen Browne

The subreport is a *control* on the main report. Therefore, if you put the
code in the main report's module (not the subreport's module), and leave
space for it, you should be fine.
 
J

jfalberg

Thanks Allen, it worked after I increased the page width from 5.3125" up to
5.5". Only thing I notice is that the page header & page footer sections
seem to get cut off when shifted over 270 twips (.1875") to the right. How
can I prevent that from happening? Otherwise I'm golden to finish this once
and for all.
 
A

Allen Browne

That should not happen. Unless this is a multi-column report, they should
behave the same as the rest of the controls. Naturally, you need to make
them narrow enough to cope with moving to the right, yet wide enough to
display the text.

Presumably you do want this header text moved as well? If not, you could add
some If conditions to test the Name of the control, and not move some of
them.
 
J

jfalberg

Interestingly while it appears everything is shifting over correctly, the
detail section still appears visible in that new 270 twip gap but it is the
page header & page footer sections where there are solid lines and a portion
of the page number is getting cut off. I tried expanding the page width and
even set the right margin to 0" but that still didn't seem to work. I wonder
if I could at least put a dummy text in there to force that to happen. I
shouldn't have to do that.
 
A

Allen Browne

Just tested with a line in the page header section, and it moved fine.

(Test was in A2007 SP1.)
 

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