<

Watch MS Access – Adding “Page ‘x’ of ‘y’” Over a Group in a Report

Posted on
9,385 Points
1,285 Views
1 Endorsement
Last Modified:
Experience Level: Beginner
5:15
Jim Dettman (EE MVE)
Independent consultant specializing in the writing of custom packages for businesses.
Learn how to number pages in an Access report over each group.

Video Steps

1. Activate two pass printing by referencing the pages property

2. Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to determine what pass your on.

3. Use an unbound control to display the page count

1
1 Comment
LVL 63

Author Comment

by:Jim Dettman (EE MVE)
Just noticed that I never actually gave the code in the tutorial:

Option Compare Database
Option Explicit

'************ Code Start *************
' This code was originally written by James H Brooks.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' James H Brooks
'

Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant
Dim GrpNamePrevious As Variant
Dim GrpPage As Integer
Dim 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!ID
    
    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

Open in new window

0
If your application will be used by financial auditors, then never ever use the delete functions to remove incorrect documents from your ledgers because financial auditors will require to audit, even cancel or reject documents and reasons for their …
A small utility that imports the tables from Older - Unsupported Microsoft Access Databases

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month