INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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.

Jobs

resetting page numbers on group change

resetting page numbers on group change

(OP)
I have a report that I'm trying to reset the page numbers at change of group.
Thread thread703-18458: How do I set page number by group??? has the code that I used. After much struggle, I finally was able to get the page numbers mostly correct.

The problem that I am having is if the details spill over onto page 2 (not a group change), the page 1 of 1 doesn't print.

CODE

If Me.Pages = 0 Then
    ReDim Preserve GrpArrayPage(Me.page + 1)
    ReDim Preserve GrpArrayPages(Me.page + 1)

    GrpNameCurrent = Me!txtPermitNo & Me!txtmp1
   ' Debug.Print Me!txtPermitNo & Left(Me.txtMP, 3)
        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
            Me!ctlGrpPages = "Page " & GrpArrayPage(Me.page) & " of " & GrpArrayPages(Me.page)
        Else
            GrpPage = 1
            GrpArrayPage(Me.page) = GrpPage
            GrpArrayPages(Me.page) = GrpPage
            Me!ctlGrpPages = "Page " & GrpArrayPage(Me.page) & " of " & GrpArrayPages(Me.page)
        End If
Else
  Me!ctlGrpPages = "Page " & GrpArrayPage(Me.page) & " of " & GrpArrayPages(Me.page)
End If
 GrpNamePrevious = GrpNameCurrent 
If I walk through the code the for statement loops through 2 times which results in both grparrayPage(me.page) and grparraypages(me.page) being 2 which prints fine on the 2nd page. Page 1 of 2 is what I can't seem to get to print.
If the group only consists of one page, page 1 of 1 prints fine.

Since the first statement checks for page = 0, I am assuming that on a group change, it automatically goes back to 0. Is this correct?
I have been trying off/on for 2 months now to get this to work properly and am totally out of ideas so any help will be greatly appreciated.

One other thing, the sample said to put the code in page footer but when I did that, nothing printed. When I moved it to the group header section, the page x of x started to print. I have the ctlGrpPages in the group footer along with a text box that says =[pages]
thanks
lhuffst

RE: resetting page numbers on group change

If you read the starred posts in the thread you referenced and the referenced website in that thread, it should all become clear.

Although I am skeptical about the second starred post about having an invisible control referencing [pages].

RE: resetting page numbers on group change

I have found (at least in previous versions) if you want to get a Page number value, you have to bind [Page] and/or {Pages] to a control in order to see the value in the code in the report.

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

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