• VB Code (97 / SR2b)

    Author
    Topic
    #358909

    Could someone advise me as to what I did wrong in the code that follows.

    I’ve made a report that prints a customer statement of account., One or more pages per customer. Where there is only one page an unbound control in the page footer should read “1 of 1”. And if there are more then one page, maybe 2 pages then the control should read on page 1 “1 of 2” and on page 2 “2 of 2”.
    I have placed this code in the PageFooter Proporty OnFormat. I must have typed something incorrectly as the code does not work .
    Thank you for your time

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

    Dim GrpArrayPage(), GrpArrayPages()
    Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
    Dim GrpPage As Integer, GrpPages 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!CustCode
    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!txtGrpPages = “Group Page” & GrpArrayPage(Me.Page) & ” of ” & GrpArrayPages(Me.Page)
    End If
    GrpNamePrevious = GrpNameCurrent

    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #536790

      Dave Thanks Kindly for the reply

      Your answer is a very good one. But sadly it is not my solution.

      My customer statements are printed in mass. One statement to a customer. I may have 36 statements and have 54 pages printed.
      Customer number one may only have one page.
      Customer number two may have two pages.
      My grouping is done on the customer.

      thank you once again

    Viewing 0 reply threads
    Reply To: VB Code (97 / SR2b)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: