Group wise page number & overall page number (1 Viewer)

Jimal

Member
Local time
Today, 22:57
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:27
Joined
Oct 29, 2018
Messages
21,358
Hi. Does your report display a consistent number of records per page?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:27
Joined
May 7, 2009
Messages
19,169
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

  • GroupNumbering.accdb
    640 KB · Views: 134

Jimal

Member
Local time
Today, 22:57
Joined
Sep 29, 2020
Messages
60
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:27
Joined
May 7, 2009
Messages
19,169
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).
 

isladogs

MVP / VIP
Local time
Today, 17:27
Joined
Jan 14, 2017
Messages
18,186
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:27
Joined
Sep 21, 2011
Messages
14,044
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:27
Joined
May 7, 2009
Messages
19,169
mr.gasman, i translated it to a2007.
 

Attachments

  • GroupNumbering.accdb
    652 KB · Views: 170

Users who are viewing this thread

Top Bottom