Reset "Page of Pages" based on Groups

jackyaz

Registered User.
Local time
Yesterday, 21:44
Joined
Nov 10, 2009
Messages
28
I found this code, but cannot get it to work.

Code:
Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
 
Private Sub PageFooterSection_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![Consultant Name]
    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

I have 3 grouping and sorting levels, Consultant Name, by which it is grouped and sorted in ascending order, then sorted by Date completed in ascending order, and finally by ID in ascending order. What I would like to be able to do is on each page footer, for "Page n of m" to appear, but to take into account grouping, so that it updates based on the number of pages for that group. How do I get it to work?
 
Which is the Main group?
 
Consultant name. I made it work, i changed the "as variant" to "as string" and added in a hidden field with control source =[Pages]. Sheer guesswork, but it works!
 

Users who are viewing this thread

Back
Top Bottom