Alternating page header in report

A

Alp Bekisoglu

Hi Experts,

How should I accomplish the task to alternate/change the page header in a
report based on even or odd pages?

The result is printed through Acrobat Distiller which will then go the print
house thus I have to have alternating headers i.e.:
if page no is odd:
PAGETITLE description A

if page no is even:
A description PAGETITLE

Thanks in advance.

Alp
 
A

Alp Bekisoglu

Just forgot to mention a few things:
Database is A2K

PAGETITLE and description is the same for all pages but the letter changes
and is derived from the detail section of the report.

Furthermore, I will also need to adjust left/right margins depending whether
the page no is odd or even.

Thanks again.

Alp
 
M

Marshall Barton

Alp said:
Hi Experts,

How should I accomplish the task to alternate/change the page header in a
report based on even or odd pages?

The result is printed through Acrobat Distiller which will then go the print
house thus I have to have alternating headers i.e.:
if page no is odd:
PAGETITLE description A

if page no is even:
A description PAGETITLE


You can do all this kind of thing using code in the page
header section's Format event procedure.

First, use the report's Open event to remember where the
detail sections' controls are positioned in design view:

Const TPI As Integer = 1440 'twips per inch
Const ADJUST As Long = .75 * TPI
Dim colPositions As New Collection

Sub Report_Open(
Dim ctl As Control
For Each ctl In Me.Section(0).Controls
colPositions.Add ctl.Left, ctl.Name
Next ctl
End Sub

The code in the Page header Format event procedure would
manipulate the controls' Left property in some manner like
this:

Sub Page_Format(
Dim ctl As Control

If Me.Page Mod 2 = 0 Then
' page number is even
Me.txtTitle.Left = 5 * TPI
Me.txtDescription.Left = .6 * TPI
Me.Letter.Left = 0
For Each ctl In Me.Section(0).Controls
ctl.Left = colPositions(ctl.Name) + ADJUST
Next ctl
Else
' page number is odd
Me.txtTitle.Left = 0
Me.txtDescription.Left = 2 * TPI
Me.Letter.Left = 5.4 * TPI
For Each ctl In Me.Section(0).Controls
ctl.Left = colPositions(ctl.Name)
Next ctl
End If
End Sub

The numbers above are in inches, change them to your actual
positions.
 
A

Alp Bekisoglu

Hi Marsh,

Thank you for the advice and the code. Before doing some guesswork with your
code (on the re-placement of fields) I tried only the OnFormat part giving
each control's left settings but it garbled up all of them to the left!
In the report page header except for the Letter (actual control name is
Text37) all the rest are labels and there are 5 of them. I need this due to
formatting and different fonts being used. Label names and their Left
settings are as follows for an odd page (I use cm as measuring unit):
Label39 0
Label40 4.683
Label41 6.376
Label22 7.328
Label27 7.328
Text37 9.471
I need them to be located as follows on an even page:
Text37 0
Label22 1.751
Label27 1.751
Label39 3.862
Label40 8.545
Label41 10.238

As you would guess I coded them as i.e. Me.controlname.Left = 8.545 and it
didn't work.

Then I added * TPI where I had set Const TPI As Integer = 567 'twips per cm
and it worked! So thanks again for leading me in the right direction. I will
keep the code for future use.

Alp
 

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