Page number for each customer

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]


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?
 
F

FPS, Romney

Marsh,
Don't mean to take up so much of your time on this issue. I added the text
box (=1, running sum over group) to the detail section per your suggestion.
However, there's only one field in the detail section for the group: a memo
field. This is what grows and can cause multiple pages, so the value of the
text box doesn't change -- it stays at 1 and Me!Line32.Visible =
(Me.txtDetailNum =1) OR (Me.Page = Me!GroupXY) will always evaluate as True.
Unless you can think of something else, what I might do is simply put the
page header fields (which contain client name, date of service, etc.) in the
group header section. That way, they'll only print on the first page of each
group. Subsequent pages for the group (if any) would not have these fields
at the top of the page. I can still include some of these fields in the page
footer, however, just to make sure that multiple-page progress notes for a
client/date of service don't get mixed up with other client-notes. The page
footer re-numbering code can make these footer-fields not visible where
Me.Page = 1.

.... All of this is so that payroll-people at the corporate office when they
manually add up the Units (which is a field printed at the top of the page)
don't duplicate this entry as they go to page 2 of a two-page note --
missing that it says "Page 2 of 2" at the bottom of the page.
Mark.
 
M

Marshall Barton

Don't mean to take up so much of your time on this issue. I added the text
box (=1, running sum over group) to the detail section per your suggestion.
However, there's only one field in the detail section for the group: a memo
field. This is what grows and can cause multiple pages, so the value of the
text box doesn't change -- it stays at 1 and Me!Line32.Visible =
(Me.txtDetailNum =1) OR (Me.Page = Me!GroupXY) will always evaluate as True.
Unless you can think of something else, what I might do is simply put the
page header fields (which contain client name, date of service, etc.) in the
group header section. That way, they'll only print on the first page of each
group. Subsequent pages for the group (if any) would not have these fields
at the top of the page. I can still include some of these fields in the page
footer, however, just to make sure that multiple-page progress notes for a
client/date of service don't get mixed up with other client-notes. The page
footer re-numbering code can make these footer-fields not visible where
Me.Page = 1.

... All of this is so that payroll-people at the corporate office when they
manually add up the Units (which is a field printed at the top of the page)
don't duplicate this entry as they go to page 2 of a two-page note --
missing that it says "Page 2 of 2" at the bottom of the page.


That kind of value should properly be in the group header,
so I agree that you should move it there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top