Reset Page Numbers

B

bw

Fredg recommends going to this site to reset page numbers:
http://www.mvps.org/access/reports/rpt0013.htm

I'm doing something wrong.

1. From where is the indicated procedure called?
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As
Integer)

I get the following procedure when I select the PageFooter, and then
select the On Format event:
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount
As Integer)

Why are they different?

2. I replace "Me!Salesperson" as indicated in the instructions with
"Me!WUID",
which has been selected in the "Sorting and Grouping" dialog box,
but I then get an error message as follows:
Run-time error '2465':
Microsoft access can't find the field 'WUID' referred to in your
expression.

It seems as though I'm putting the code at the site referred to by Fredg
in the wrong event...so where is it suppose to go?
If 'WUID' is recognized by the 'Sorting and Grouping' dialog, then why
doesn't it recognize it in the event procedure?

Thanks for your help,
Bernie
 
F

fredg

Fredg recommends going to this site to reset page numbers:
http://www.mvps.org/access/reports/rpt0013.htm

I'm doing something wrong.

1. From where is the indicated procedure called?
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As
Integer)

I get the following procedure when I select the PageFooter, and then
select the On Format event:
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount
As Integer)

Why are they different?

2. I replace "Me!Salesperson" as indicated in the instructions with
"Me!WUID",
which has been selected in the "Sorting and Grouping" dialog box,
but I then get an error message as follows:
Run-time error '2465':
Microsoft access can't find the field 'WUID' referred to in your
expression.

It seems as though I'm putting the code at the site referred to by Fredg
in the wrong event...so where is it suppose to go?
If 'WUID' is recognized by the 'Sorting and Grouping' dialog, then why
doesn't it recognize it in the event procedure?

Thanks for your help,
Bernie

Bernie,
1) You're getting a different Page Footer Sub designation because
you're using a different version of Access from when the MVPS code was
written.

Place the code in the Page Footer Format event of your report. Use the
Private Sub ... etc .. wording as generated by your Access version.

2) In the code for the page footer format event, change
GrpNameCurrent = Me!Salesperson
to
GrpNameCurrent = Me!WUID

That code does work.
 
B

bw

fredg said:
Bernie,
1) You're getting a different Page Footer Sub designation because
you're using a different version of Access from when the MVPS code was
written.

Place the code in the Page Footer Format event of your report. Use the
Private Sub ... etc .. wording as generated by your Access version.

2) In the code for the page footer format event, change
GrpNameCurrent = Me!Salesperson
to
GrpNameCurrent = Me!WUID

That code does work.

Thanks for the reply Fred!
I suspected as much, but it still doesn't work.
Here is the code I'm using per the MVPS site, where I get the Run-time
error '2465':

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim I As Integer
MsgBox Me!WUID
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page + 1)
ReDim Preserve GrpArrayPages(Me.Page + 1)
GrpNameCurrent = Me!WUID ' This is where the error occurs
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
 
F

fredg

Thanks for the reply Fred!
I suspected as much, but it still doesn't work.
Here is the code I'm using per the MVPS site, where I get the Run-time
error '2465':

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim I As Integer
MsgBox Me!WUID
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page + 1)
ReDim Preserve GrpArrayPages(Me.Page + 1)
GrpNameCurrent = Me!WUID ' This is where the error occurs
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 you get a message with the correct data when the report runs this
part of your code?

Dim I As Integer
MsgBox Me!WUID '<<<<<
If Me.Pages = 0 Then

What happens if you use the dot instead of the bang.

GrpNameCurrent = Me.WUID

When you type = Me.
does the field WUID show up in the available properties/fields
drop-down list?

I see nothing here in the code, so it must be somewhere else.
Is WUID included in the Report record source?
Is the name of the Report's Group Header
WUID Header?

Does the report otherwise correctly run without this code?

If you continue to be puzzled with this, if you wish to send it to me,
I'll be happy to take a look. Remove any extra data so that I see just
this report and any tables/queries/forms needed to run it.
Send it to

jandf at symbol adelphia dot net

without spaces

Make sure you write "Page Number Database" as the subject line
otherwise I won't open it (I won't even see it).
 
F

fredg

On Fri, 15 Dec 2006 10:23:34 -0700, bw wrote:

**** Snipped ****
Here is my analysis of your database.

1) You did not include any fields or queries so I cannot actually run
the report and get the same results you would.

2) You had the control that displays the group page count
"ctlGrpPages" set to Not visible in the page Footer.
Set it's Visible property = Yes.

3) I added a sample table with a WUID (text) field and a PageNum
(Number) field, and entered some appropriate data. I then changed the
report's record source to this new table so that I could run it.

I also got that "Could not find the WUID field" message, and it was
because there is no field in the report itself that uses the WUID
field as it's control source.
I then dragged the WUID field from the field list tool button and
placed it in the WUID Group Footer section as you did not have a Group
Header.

4) I left the WUID Footer section Not Visible.

5) I increased the size of the detail section (just as a test because
of my limited number of records). When run, the number of pages in the
group appeared as it was supposed to, 1 of 2, 2 of 2, 1 of 1, 1 of 1..

6) To recap:
Change the Visible property of the ctlGrpPages to Yes.
Add the WUID field to the report (I added it to the Group Footer, but
you might want to consider adding a Group Header and placing it there.
The name of the group will then appear at the top of the page, if you
set it's visible property to Yes).

That is really all you need do.

Hope this is clear.

Fred
 
B

bw

Perfectly clear Fred!

Thank you so much for taking the time to discover my errors, even though
I was unable to provide you with data.
I'm not sure I would have ever found the problem of the WUID field not
appearing in the report itself. My report now works fine!

When I do Google searches for solutions to my problems in reports, my
first search includes "fredg" as the author, as you most often have the
easiest to read solutions to "our" problems.

Your help is appreciated, your solutions are easy to read, and they are
mostly to the point.

Thanks, from a lot of us out here...

Bernie
 

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