Help please!
I'm trying to set group page # of group pages for each new group in the page footer of a report.
The report is grouped by Billing_Cost_Center. I have an unbound text box in the page footer named ctlGrpPages, and I have another text box in the page footer with a control source of ="Page " & [Page] & " of " & [Pages] and it's visible property = no.
I've found a few code samples in posts, but I can't get any of them to work. Here is the code I am trying:
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!Billing_Cost_Center
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 = "Billing_Cost_Center" & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
I've also downloaded a sample file with report that works fine but when I try to recreate the report using the same data and code I also can't get it to work. Can anyone see what I'm doing wrong?

I'm trying to set group page # of group pages for each new group in the page footer of a report.
The report is grouped by Billing_Cost_Center. I have an unbound text box in the page footer named ctlGrpPages, and I have another text box in the page footer with a control source of ="Page " & [Page] & " of " & [Pages] and it's visible property = no.
I've found a few code samples in posts, but I can't get any of them to work. Here is the code I am trying:
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!Billing_Cost_Center
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 = "Billing_Cost_Center" & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
I've also downloaded a sample file with report that works fine but when I try to recreate the report using the same data and code I also can't get it to work. Can anyone see what I'm doing wrong?
