Count Records On Each Page In A Report

M

Marshall Barton

Steve said:
How can the number of records on each page of a report be counted?


Add a text box (named txtDtlCnt) to the detail section and
set its expression to =1 and RunningSum to Over All.

Then add code to the page footer section's Format event:

Static lngPrevCnt As Long
Me.[page footer text box] = Me.txtDtlCnt - lngPrevCnt
lngPrevCnt = Me.txtDtlCnt

If you are using the Pages property, then move the variable
declaration to the top of the module and add a line of code
to the report header section's Print event:

lngPrevCnt = 0
 
S

Steve

Marsh,

I appreciate your response!

Two issues .......
1. Me.[page footer text box] gives 1 more than the number of records

2. Please explain the last paragraoh about the Pages property (I know
what the pages property is)
a) Where do you mean using the pages property?
b) What variable declaration do you mean? (Static lngPrevCnt As
Long?)
c) Top of what module?

Thanks!

Steve



Marshall Barton said:
Steve said:
How can the number of records on each page of a report be counted?


Add a text box (named txtDtlCnt) to the detail section and
set its expression to =1 and RunningSum to Over All.

Then add code to the page footer section's Format event:

Static lngPrevCnt As Long
Me.[page footer text box] = Me.txtDtlCnt - lngPrevCnt
lngPrevCnt = Me.txtDtlCnt

If you are using the Pages property, then move the variable
declaration to the top of the module and add a line of code
to the report header section's Print event:

lngPrevCnt = 0
 
M

Marshall Barton

Steve said:
Two issues .......
1. Me.[page footer text box] gives 1 more than the number of records

I don't see how that's possible, unless you did not put the
code in the page footer section's event.

2. Please explain the last paragraoh about the Pages property (I know
what the pages property is)
a) Where do you mean using the pages property?

If you use it anywhere in the report the variable will have
to be (re)initiaalized in the report header section's event.
b) What variable declaration do you mean? (Static lngPrevCnt As
Long?)

Yes, but it should probably be Private instead of Static.
c) Top of what module?

The report's module.
 
P

pinkpanther

Marsh,

I appreciate your response!

Two issues .......
1.    Me.[page footer text box] gives 1 more than the number of records


It works great for me with this change! ;^)

lngPrevCnt = 1
 

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