Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I detect odd/even page numbers 1

Status
Not open for further replies.

AccessGuruCarl

Programmer
Jul 3, 2004
471
US
I have a report that, when its an odd number page, text in the header is right justified, if it's an even number page then its left justified.

Presently I'm doing this with a Select Case Statement

Select Case Reports!Tax.Page
Case 1,3,5,7,9,11,13 etc....
txtHeaderCtl.TextAlign = Right
Case Else
txtHeaderCtl.TextAlign = Left
End Select

I'd rather test for Odd or Even number if possible... Due to unknown number of pages in future reports.

Thanks in advance...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Hi!
Try this as your test:
Code:
If Reports!Tax.Page/2 = Int(Reports!Tax.Page/2)Then
     txtHeaderCtl.TextAlign = Left
Else
     txtHeaderCtl.TextAlign = right
End If
Hope this helps!

Tom


Born once die twice; born twice die once.
 
Hi Tom,

Worked like a charm with a slight modification.

It requires the integer value instead of boolean.

Here is the working code for other users.

Code:
    ' Align txtHeaderCtl based on page number
    If Reports!Tax.Page / 2 = Int(Reports!Tax.Page / 2) Then
        txtHeaderCtl.TextAlign = 1    'Align Left / Even Number
    Else
        txtHeaderCtl.TextAlign = 3    'Align Right / Odd Number
    End If

Thanks Again, Here is a STAR...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Glad to help - and thanks for the star!

Tom

Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top