Mendip Data Systems

Database applications for businesses and schools



Dim GrpArrayPage(), GrpArrayPages()

Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant

Dim GrpPage As Integer, GrpPages As Integer


Private Sub PageHeaderSection_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.[Activity Code]

   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


     GrpPage = 1

     GrpArrayPage(Me.Page) = GrpPage

     GrpArrayPages(Me.Page) = GrpPage

   End If


   Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)

 End If

 GrpNamePrevious = GrpNameCurrent


End Sub

Code Samples for Businesses, Schools & Personal Use

Updated 21/12/2017  


If you use grouping in a report, you may wish to restart the page numbering for each group

To do so:

1. add an unbound control ctlGrpPages in the page footer section

2. use the following code in your report



Report Group Pages

Return to Code Samples Page