dbTalk Databases Forums  

Report Numbering

comp.database.ms-access comp.database.ms-access


Discuss Report Numbering in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dave B
 
Posts: n/a

Default Report Numbering - 05-12-2004 , 08:56 AM






I need to number a report in a loop sequence numbering all pages 1-7.
When 7 is reached the code needs to go back to 1 and restart the
numbering process.

It does not matter whether the report is 5 pages or 500 pages, the
sequence must be kept.

Any ideas on this or where I might find some leads to help me out? I
am guessing that I am going to need a VBA module running being the
report...

Thank you so much in advance,

Dave

Reply With Quote
  #2  
Old   
Sam P
 
Posts: n/a

Default Re: Report Numbering - 05-12-2004 , 02:46 PM






The following should work for you

1) Place a label control in the report page footer called lblPage
2) Copy this code into your report module
3) delete Option Compare Database and Option Explicit if they already exist
i.e. only 1 of each allowed



Option Compare Database
Option Explicit

' These vars are here because we don't want to loose their value as
' PageFooter_Format() is repeatedly called - Static vars in
' PageFooter_Format() might work as well
Dim intPgNbr As Integer
Dim intPgOffset As Integer
Dim blnSwitch As Boolean


Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
'----------------------------------------------
' initialize the vars - probably not required
'----------------------------------------------
If Nz(intPgNbr, 0) = 0 Then

intPgNbr = 0

End If

If Nz(intPgOffset, 0) = 0 Then

intPgOffset = 0

End If
If Nz(blnSwitch, False) = False Then
blnSwitch = False

End If
'------------------------
' The work starts here
'------------------------
If blnSwitch Then

intPgOffset = Page - 1
blnSwitch = False

End If

If Page Mod 7 = 0 Then
blnSwitch = True ' set the trap to update intPgOffset the next
' time PageFooter_Format() is called

End If

intPgNbr = Page - intPgOffset
Me!lblPage.Caption = "Page " & intPgNbr
'Note: used a label because Access doesn't like to update textboxes on
the fly
' BE SURE to put some text (I use "DO NOT DELETE") in the label
because
' Access automatically deletes labels with no text


End Sub

"Dave B" <dbold001 (AT) yahoo (DOT) com> wrote

Quote:
I need to number a report in a loop sequence numbering all pages 1-7.
When 7 is reached the code needs to go back to 1 and restart the
numbering process.

It does not matter whether the report is 5 pages or 500 pages, the
sequence must be kept.

Any ideas on this or where I might find some leads to help me out? I
am guessing that I am going to need a VBA module running being the
report...

Thank you so much in advance,

Dave



Reply With Quote
  #3  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Report Numbering - 05-12-2004 , 04:07 PM



Dave:
Yes, a little VBA

The page number goes into the page footer .
If you autogenerate a report with the wiazard you will see:
="Page " & [Page] & " of " & [Pages]
in the footer.
I don't know if you want number of pages. You can just remove that.
The page footer has properties. IN properties there are events.
You need to goto the on format event.
It will look like this.
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
End Sub

You need to add one line that will make it look like this.
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page > 7 Then Page = 1
End Sub

That will solve your problem.

Good luck
Ira Solomon


On 12 May 2004 06:56:27 -0700, dbold001 (AT) yahoo (DOT) com (Dave B) wrote:

Quote:
I need to number a report in a loop sequence numbering all pages 1-7.
When 7 is reached the code needs to go back to 1 and restart the
numbering process.

It does not matter whether the report is 5 pages or 500 pages, the
sequence must be kept.

Any ideas on this or where I might find some leads to help me out? I
am guessing that I am going to need a VBA module running being the
report...

Thank you so much in advance,

Dave


Reply With Quote
  #4  
Old   
Sam P
 
Posts: n/a

Default Re: Report Numbering - 05-12-2004 , 07:01 PM



All this time and I didn't know that Page was assignable!!!
Much easier solution.

"Ira Solomon" <isolomon (AT) solomonltd (DOT) com> wrote

Quote:
Dave:
Yes, a little VBA

The page number goes into the page footer .
If you autogenerate a report with the wiazard you will see:
="Page " & [Page] & " of " & [Pages]
in the footer.
I don't know if you want number of pages. You can just remove that.
The page footer has properties. IN properties there are events.
You need to goto the on format event.
It will look like this.
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
End Sub

You need to add one line that will make it look like this.
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page > 7 Then Page = 1
End Sub

That will solve your problem.

Good luck
Ira Solomon


On 12 May 2004 06:56:27 -0700, dbold001 (AT) yahoo (DOT) com (Dave B) wrote:

I need to number a report in a loop sequence numbering all pages 1-7.
When 7 is reached the code needs to go back to 1 and restart the
numbering process.

It does not matter whether the report is 5 pages or 500 pages, the
sequence must be kept.

Any ideas on this or where I might find some leads to help me out? I
am guessing that I am going to need a VBA module running being the
report...

Thank you so much in advance,

Dave




Reply With Quote
  #5  
Old   
Andrew Backer
 
Posts: n/a

Default Re: Report Numbering - 05-14-2004 , 12:01 PM



Why not just use something like this :

=iif( ([Page] mod 7) = 0, 7, [page] mod 7)

FYI : iif ( expression, <when true>, <when false> )

This will give you your wrap at 7, and since 7 mod 7 is zero just use
the iff to show the 7 in that case. I tested this and it works. I
suppose you cound even make it configurable pretty easy too.

Hope this helps,

- Andrew Backer

Dave B wrote:
Quote:
I need to number a report in a loop sequence numbering all pages 1-7.
When 7 is reached the code needs to go back to 1 and restart the
numbering process.

It does not matter whether the report is 5 pages or 500 pages, the
sequence must be kept.

Any ideas on this or where I might find some leads to help me out? I
am guessing that I am going to need a VBA module running being the
report...

Thank you so much in advance,

Dave

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.