Psycholicon
Registered User.
- Local time
- Today, 07:21
- Joined
- Aug 14, 2007
- Messages
- 33
I don't know how common this problem is, but it was vital for my situation, and there isn't a set way to do it in Access. If you have a Report that displays a 'cascading' type recordlist (many records based off of one field placed in a Header) and want to have the individual values of the header to have their own page numbering, Put this code in the Declarations
And use this code in the 'Format' event of the Report's Page Footer
Hope this helps someone, I sure was frustrated trying to find how to do it!
Code:
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
And use this code in the 'Format' event of the Report's Page Footer
Code:
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.[B]THE CONTROL YOU WANT TO GROUP BY[/B]
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.[B]Name of an UNBOUND Text box[/B] = " " & "Page" & " " & GrpArrayPage(Me.Page) & " of " & " " & GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
Hope this helps someone, I sure was frustrated trying to find how to do it!
Last edited by a moderator: