M
Marshall Barton
Sorry Daryl, I thought I answered this.
I don't see how that code can get that error unless the
array has been reset in some unknown way. You might try
opening the report from the closed state instead of
switching from design view. Probably won't make a
differencem but who knows.
If it consistently gets the same error, try to track it down
by placing break points on a few strategic lines and
checking the value of Page and the array's Upper/Lower
bounds to see what the values are and where/when they go
wrong.
--
Marsh
MVP [MS Access]
I don't see how that code can get that error unless the
array has been reset in some unknown way. You might try
opening the report from the closed state instead of
switching from design view. Probably won't make a
differencem but who knows.
If it consistently gets the same error, try to track it down
by placing break points on a few strategic lines and
checking the value of Page and the array's Upper/Lower
bounds to see what the values are and where/when they go
wrong.
--
Marsh
MVP [MS Access]
Daryl said:For some case with only 1 page, it works. However, for the case more than 2
pages, it shows:
"run-time error 9: subsrcript out of range". The
code errors-out toward the bottom at the line beginning: "Me!ctlGrpPages =
....".
This is the same result as mentioned by "FPS, Romney ". May I doing anthing
wrong? How can I check that?
Daryl said:Here below is the codes I put into "PageFooter_Format" (whihc is copied from
the webpage but change the "Me.!Salesperson" to "Me![cust_no]"):
Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
Private Sub PageFooter_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![cust_no]
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!ctlGrpPages = "Group Page " & GrpArrayPage(Me.page) & " of " &
GrpArrayPages(Me.page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
Do I have anything wrong?