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