Group wise page number & overall page number

Jimal

Member
Local time
Today, 22:14
Joined
Sep 29, 2020
Messages
60
dear lifesavers.

I have generated a 1000 page report with page numbers (say page x of y)
I have multiple groups within this report(each grouped & sorted) - say group A, group B and so on
I would like to have a section wise page number (say for section A, page nos be like A1 of A100) in addition to my overall page number..

I know this is fancy but its all the end requirement and im struck up with it

any help will be appreciated
 
Hi. Does your report display a consistent number of records per page?
 
i have made something similar before.
this can only be accomplished on "Print Preview" and not
on any other report view.

see the attached report.
 

Attachments

Hi @arnelgp thanks this is my exact requirement.
however I have my own ignorant doubts over this..pls consider
1) how does the module "called" while report printing - pls explain ( I mean by which event that module is executed??)
2) there is a count(*) at the report footer..how its not getting printed in report

and a more dumb doubt..
why should this code be written over a module and not in the eventproceedure property of the report itself
 
1. the class is called on Open event of the report and in PageHeaderSection_Format event.
2. the Count(*) is in the Report Footer, so it will print on the Last Page.

the last doubt:

you can put all the code in the report's code.
i made it into a Class so that it can be called from Other report also (not duplicating
the code on each report).
 
Here's how I do it based on code I found well over 15 years ago at http://access.mvps.org/access/reports/rpt0013.htm:

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 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
    Else
      GrpPage = 1
      GrpArrayPage(Me.Page) = GrpPage
      GrpArrayPages(Me.Page) = GrpPage
    End If
  Else
    Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
  End If
  GrpNamePrevious = GrpNameCurrent

End Sub

I expect Arnelgp's code is similar to the above but I haven't checked
 
1. the class is called on Open event of the report and in PageHeaderSection_Format event.
2. the Count(*) is in the Report Footer, so it will print on the Last Page.

the last doubt:

you can put all the code in the report's code.
i made it into a Class so that it can be called from Other report also (not duplicating
the code on each report).
@arnelgp
Any chance you can put up a version that 2007 will open please.? I'd like to see that.?
TIA
 

Users who are viewing this thread

Back
Top Bottom