Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Reports FAQ

How To

How do you Print First and Last Page Numbers for Report Groups? by dnelson24
Posted: 9 Aug 02

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
        GrpPage = 1
        GrpArrayPage(Me.Page) = GrpPage
        GrpArrayPages(Me.Page) = GrpPage
    End If
    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!

Back to Microsoft: Access Reports FAQ Index
Back to Microsoft: Access Reports Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close