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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resetting page numbers on group change

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
I have a report that I'm trying to reset the page numbers at change of group.
Thread [blue]thread703-18458[/blue] 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
 
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].
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top