Reset Page No. and No. Of Pages on Report (1 Viewer)

RogerCH

New member
Local time
Today, 08:27
Joined
Mar 27, 2016
Messages
7
I have come across the following piece of code that I was hoping would reset the page number and number of pages (displayed in the Page Footer unbound control named ctlGrpPages) on the change of group (txtOrgName) within my report.

My report has 4 Organisations (txtOrgName), producing 8 pages, so I am expecting …
Page 1 of 2 / Page 2 of 2
Page 1 of 1
Page 1 of 3 / Page 2 of 3 / Page 3 of 3
Page 1 of 2 / Page 2 of 2

As I Page Forward the report and step through the code it never seems to execute the step Me!ctlGrpPages = "Group Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)


Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, 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!txtOrgName
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 = "Group Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent

End Sub


I have also tried by introducing a GroupFooter format event but to no avail.
Any help would be gratefully received.

Private Sub OrgNameGroupFooter_Format(Cancel As Integer, FormatCount As Integer)

Page = 1

End Sub
 

Minty

AWF VIP
Local time
Today, 15:27
Joined
Jul 26, 2013
Messages
10,355
Are you looking at the report in Report view, as that doesn't fire the format events?
You have to look at it in print preview.
 

RogerCH

New member
Local time
Today, 08:27
Joined
Mar 27, 2016
Messages
7
Hi Minty

I have been previewing my report via the Print View but it never seems to execute a second pass.
From reading many threads on the subject, from various forums I have now added a control in the page footer containing =[Pages] and obscured it.

This now seems to do the trick but I fail to understand why
(Possibly because this is now the only place in the report that [Pages] is being called?)

Regards
 
Last edited:

Users who are viewing this thread

Top Bottom