Grouped Report: Page (n of n) and Page Headers (1 Viewer)

Bombshell Disaster

Registered User.
Local time
Today, 08:07
Joined
Nov 21, 2007
Messages
32
Hi All

I have a grouped report that I want to display page (n of n) page 1 of 3.

I also then want to display page headers on the subsequent pages of the grouped report but not the first page.

I.e. Whole report as 10 pages, made of three grouped reports.
Report 1 - Page 1 of 3 - Display pages header section on pages 2 & 3.
Report 2 - Page 1 of 3 - Display pages header section on pages 2 & 3.
Report 3 - Page 1 of 4 - Display pages header section on pages 2,3 and 4.

I can achieve showing just page(n) on each change in group.
Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub
I can also achieve showing page headers on pages other than the first page, though it does it for all the pages apart from the first page of the whole report, because it does not take into account the page numbers resetting.
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
If Me.Page > 1 Then
Me.Report.Section(acPageHeader).Visible = True
Else
Me.Report.Section(acPageHeader).Visible = False
End If
End Sub
I have spent all day looking through solutions, and while the same thing has been mentioned many times on this forum, there has not been a solution.

Hope to hear from you guys soon..

Thanks
 

Padwan

Registered User.
Local time
Today, 08:07
Joined
Jan 17, 2012
Messages
28
I don't know if you are checking this thread anymore or have found the same solution
but here is the code i used and i will include the link to where i found it with step by step instructions on how to place it in your report


Option Compare Database
Dim DB As Database
Dim GrpPages As Recordset
Function GetGrpPages()
'Find the group name.
GrpPages.Seek "=", Me![Aname]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![Page Number]
End If
End Function

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
'Find the group.
GrpPages.Seek "=", Me![Aname]

If Not GrpPages.NoMatch Then
'The group is already there.
If GrpPages![Page Number] < Me.Page Then
GrpPages.Edit
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
Else
'This is the first page of the group. Therefore, add it.
GrpPages.AddNew
GrpPages![Aname] = Me![Aname]
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
End Sub



Private Sub Report_Open(Cancel As Integer)
Set DB = DBEngine.Workspaces(0).Databases(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From [Category Group Pages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("Category Group Pages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"
End Sub

Private Sub Report_Page()
If Me.Page Mod 3 = 0 Then
Me.PageHeaderSection.Visible = False
Me.PageFooterSection.Visible = True
Else
Me.PageHeaderSection.Visible = True
Me.PageFooterSection.Visible = True
End If
End Sub


website i found most of the code at with step by step instructions
http://support.microsoft.com/kb/841779. i hope this helps you guys. :)
 

Users who are viewing this thread

Top Bottom