mvps.org code: page numbers for groups on report

D

Dale

No matter what I have tried, I cannot get this code to work, in fact the
result doesn't even appear in the unbound text box in the footer of the
report. I liked the fact that the code was lightweight. I'm sure I'm
missing something very simple!
Thanks for any help.

In the footer of the report, unbound Text Box properties: name:ctlGrpPages,
visible yes, control source left blank, in the page header: Text Box
properties: name:OwnerGrp, control source: owner, Owner Footer: force new
page after section.

Option Compare Database
Option Explicit

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

Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
Dim i As Integer
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page + 1)
ReDim Preserve GrpArrayPages(Me.Page + 1)
GrpNameCurrent = Me!OwnerGrp
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
End Sub
 
D

david epsom dot com dot au

Does the code get executed? If you put a break point in the code,
does it get there? Have you confused group footer/ page footer/
report footer ?

(david)
 
D

Dale

Yes the code executes..but I can only get it to run until the first page is
displayed...the controls are all in the proper footers i.e. page
footer...where you would normally enter a page number.
 
D

Dale

Ok I got it to work..I added another unbound text box in the page footer
with the control source set to "=[pages]", no mention of that in the
instructions...
Thanks for your help..
 
C

Chris Nebinger

I remember coming across this issue before. Access
doesn't know how many pages it has, but putting in the
Pages property forces it to. Anway, see if there is a
feedback section on the Access Web and submit it.


Chris Nebinger

-----Original Message-----
Ok I got it to work..I added another unbound text box in the page footer
with the control source set to "=[pages]", no mention of that in the
instructions...
Thanks for your help..

Dale said:
Yes the code executes..but I can only get it to run until the first page
is displayed...the controls are all in the proper footers i.e. page
footer...where you would normally enter a page number.


.
 

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