Repost - Custom Page Numbering

T

Tara

I posted this last week, but never got any responses. I'm reposting in hopes
that someone will read it and be able to offer some advice.

I need to number the pages of a report based on group. So, group A could
have pages numbered 1, 2, and 3, and group B could have pages numbered
1,2,3,4, and 5, etc. I tried using this code suggested from The Access Web
http://www.mvps.org/access/reports/rpt0013.htm but I keep getting the
following error: The expression on Format you entered as the event property
setting produced the following error: Statement Invalid outside Type block.
I do have another small piece of code in the same event that I use to set the
value of another textbox, but even removing it doesn't fix the issue, so I
don't think that has anything to do with it. Here's the code as I typed it
(minus my extra bit of code)...maybe I mis-typed and am overlooking the issue:

Dim i As Integer
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page + 1)
ReDim Preserve GrpArrayPages(Me.Page + 1)
GrpNameCurrent = Me!County
If GrpNameCurrent = GrpNamePrevious Then
GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
GrpPages = GrpArrayPage(Me.Page)
For i = Me.Page - ((GrpPages) - 1) To Me.Page
GrpArrayPages(i) = GrpPages
Next i
Else
GrpPage = 1
GrpArrayPage(Me.Page) = GrpPage
GrpArrayPages(Me.Page) = GrpPage
End If
Else
Me!ctlGrpPages = "Group Page" & GrpArrayPage(Me.Page) & "of" &
GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent


Any help is greatly appreciated!
 
J

John Spencer MVP

If all you need is page 1, 2, 3, 1,2,...8 and not Page 1 of 3, Page 2 of 3,
Page 3 of 3, Page 1 of 8, Page 2 of 8 ... then there is a much simpler solution.

Just reset the value of page to 1 whenever the GROUP changes. This assumes
that you have grouped the records and have a group header (It can be invisible
or it can be set to zero height) and it assumes that you are starting a new
page every time the group changes.

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
Me.Page = 1
End Sub

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
T

Tara

Unfortunately, I do need page 1 of 3, etc. It didn't occur to me that it
would make a difference. I apologize for not clarifying that in my post.
 
D

Douglas J. Steele

That code is supposed to be an Event Procedure for the Format event of
PageFooter object.

Look carefully at the example at the site you're citing: there should be
three lines at the top of the module

Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer

the following should be directly before the code you've quoted

Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)

with

End Sub

after.
 

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