Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you Print First and Last Page Numbers for Report Groups?

How To

How do you Print First and Last Page Numbers for Report Groups?

by  dnelson24  Posted    (Edited  )
Step1: Open your report in Design View.

Step2: Make sure that in your Group Hearder Section under properties that you have Force New Page set to None and On Format is blank.

Step3: Make sure in the Group Footer Section under properties that you have Force New Page set to None and On Format is blank.

Step4: Goto Insert on the Menu bar and select Page Numbers, select Page N of M, select Bottom of Page(assuming you want the page info at the bottom of the page), select Alignment, and Show number on First Page if desired.

Step5: For the box you just created in Step4 select properties and make Visible = No.

Step6: Open your tool box and and click the [ab|] button, create an unbound text box in the Page Footer section of your report.

Step7: Delete only the Label box for the unbound text box you created in Step6. You won't need the Label.

Step8: In properties on the unbound text box you just created type ctlGrpPages in the Name field under the All tab.

Step9: Goto View on the Menu bar and select Code. Once Visual Basic windows opens be sure you select PageFooterSection and Format in the 2 boxes on the right above the large entry box where the code below will be pasted!

Step10: Paste the code below this line into the large entry box:

Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer


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

End Sub

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!yournamehere
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

Step11: Make sure that this parameter:
GrpNameCurrent = Me!yournamehere
has your Group Header name in place of Name!
This can be found in the report design view on the gray bar for the section called (yourname Header)!

Step12: Save and close the VB screen.

Step13: View the report. The unbound text box should read Page 1 of ? and as you scroll through the pages you should see with the next changed value for Group Header the page number change to Page 1 of ? for that group!

Hope this is a detailed enough procedure for any novice to be able to complete this function! Good Luck!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top