Alternating Margins

D

Darrell

Hi, apologies to the newsgroup; I've been pestering it alot in the last
couple of days.

But, one more question. I would like to have a report print with
alternating left and right margins for the proverbial report binding
issue. Is there a way to do this? Or, maybe I would better express this
as: "What is the best way to do this?"

Thank you, everyone, for your help in advance!

Darrell
 
F

fredg

Hi, apologies to the newsgroup; I've been pestering it alot in the last
couple of days.

But, one more question. I would like to have a report print with
alternating left and right margins for the proverbial report binding
issue. Is there a way to do this? Or, maybe I would better express this
as: "What is the best way to do this?"

Thank you, everyone, for your help in advance!

Darrell

As I often adapt code for a particular purpose, I haven't checked that
this is accurate in a very long time.
Try it. You may need to make a few changes.

You can move the left position of each control as needed for
each even page, then back for each odd page.

In the Code 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.

*** You may wish to make the following change.
In Design View, set ALL the controls left position
to what you wish for the EVEN pages.
Then change the above coding, from:
ElseIf Me.[Page] Mod 2 = 0 Then MoveMargin = 1440
To:
ElseIf NOT Me.[Page] Mod 2 = 0 Then MoveMargin = 1440

Remember... 1440 = 1 inch of movement.
Try it both ways and see if which layout suits your needs better.****
 
D

Darrell

fredg said:
Hi, apologies to the newsgroup; I've been pestering it alot in the last
couple of days.

But, one more question. I would like to have a report print with
alternating left and right margins for the proverbial report binding
issue. Is there a way to do this? Or, maybe I would better express this
as: "What is the best way to do this?"

Thank you, everyone, for your help in advance!

Darrell

As I often adapt code for a particular purpose, I haven't checked that
this is accurate in a very long time.
Try it. You may need to make a few changes.

You can move the left position of each control as needed for
each even page, then back for each odd page.

In the Code 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.

*** You may wish to make the following change.
In Design View, set ALL the controls left position
to what you wish for the EVEN pages.
Then change the above coding, from:
ElseIf Me.[Page] Mod 2 = 0 Then MoveMargin = 1440
To:
ElseIf NOT Me.[Page] Mod 2 = 0 Then MoveMargin = 1440

Remember... 1440 = 1 inch of movement.
Try it both ways and see if which layout suits your needs better.****
Fred,
Thank you. This is almost working... For some reason I haven't yet
deciphered the format page is firing twice for page 1 both at the
beginning and end (first and second passes?), and the second time, it is
moving the controls back to the position for an odd page. I'm confused
(not to mention frustrated). So, I'm going to go home and rest up and
try this again tomorrow. Thank you for your help. I feel certain it's
just a minor glitch somewhere but I can't seem to put my finger on it.
So, thanks again, and I'll look for a post tomorrow if you have any
ideas, and I'll also post back my progress.

Darrell
 
D

Darrell

fredg said:
Hi, apologies to the newsgroup; I've been pestering it alot in the last
couple of days.

But, one more question. I would like to have a report print with
alternating left and right margins for the proverbial report binding
issue. Is there a way to do this? Or, maybe I would better express this
as: "What is the best way to do this?"

Thank you, everyone, for your help in advance!

Darrell

As I often adapt code for a particular purpose, I haven't checked that
this is accurate in a very long time.
Try it. You may need to make a few changes.

You can move the left position of each control as needed for
each even page, then back for each odd page.

In the Code 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.

*** You may wish to make the following change.
In Design View, set ALL the controls left position
to what you wish for the EVEN pages.
Then change the above coding, from:
ElseIf Me.[Page] Mod 2 = 0 Then MoveMargin = 1440
To:
ElseIf NOT Me.[Page] Mod 2 = 0 Then MoveMargin = 1440

Remember... 1440 = 1 inch of movement.
Try it both ways and see if which layout suits your needs better.****

Fred:
I did have to modify the code to account for whether the report ended on
an odd or even page since ChangeMargins would leave the controls in
the EVEN position if the report had an even number of pages, and vice
versa. Thus, the first page would "inherit" the placement of the last
page of the report on the "formatter's" second pass since page 1 set
MoveMargin to 0.
What I did was bypass the report header calling of ChangeMargins and, on
format of the page header, check the (last) value of MoveMargin,
changing it if it was negative and zeroing it out if it was positive.
This seemed to work nicely.
Hope I handled this okay.

Thanks again.

Darrell
 
M

Marshall Barton

Darrell said:
fredg said:
Hi, apologies to the newsgroup; I've been pestering it alot in the last
couple of days.

But, one more question. I would like to have a report print with
alternating left and right margins for the proverbial report binding
issue. Is there a way to do this? Or, maybe I would better express this
as: "What is the best way to do this?"

Thank you, everyone, for your help in advance!

Darrell

As I often adapt code for a particular purpose, I haven't checked that
this is accurate in a very long time.
Try it. You may need to make a few changes.

You can move the left position of each control as needed for
each even page, then back for each odd page.

In the Code 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.

*** You may wish to make the following change.
In Design View, set ALL the controls left position
to what you wish for the EVEN pages.
Then change the above coding, from:
ElseIf Me.[Page] Mod 2 = 0 Then MoveMargin = 1440
To:
ElseIf NOT Me.[Page] Mod 2 = 0 Then MoveMargin = 1440

Remember... 1440 = 1 inch of movement.
Try it both ways and see if which layout suits your needs better.****

Fred:
I did have to modify the code to account for whether the report ended on
an odd or even page since ChangeMargins would leave the controls in
the EVEN position if the report had an even number of pages, and vice
versa. Thus, the first page would "inherit" the placement of the last
page of the report on the "formatter's" second pass since page 1 set
MoveMargin to 0.
What I did was bypass the report header calling of ChangeMargins and, on
format of the page header, check the (last) value of MoveMargin,
changing it if it was negative and zeroing it out if it was positive.
This seemed to work nicely.


I think it might be cleaner to change the report header code
to be the same as the Page header code (or put that code in
another Sub and call it from both places). This way the
report header would not know or care about the last page.
 

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