Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Count Records On Each Page In A Report

170 views
Skip to first unread message

Steve

unread,
Aug 6, 2009, 3:30:19 PM8/6/09
to
How can the number of records on each page of a report be counted?

Thanks,

Steve


Rich P

unread,
Aug 6, 2009, 4:16:58 PM8/6/09
to
One method is to programmatically set a pagebreak for a given number of
records. If you don't want to set a pagebreak, you can arrange your
textbox controls to accommodate a specified number of records per page.
This would be done manually - like set the textboxes one way - run your
report - and keep adjusting the textboxes until you have achieved the
desired number of rows perpage.

If there is a more elegant way to do this - hopefully someone will
share.

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Marshall Barton

unread,
Aug 6, 2009, 4:19:19 PM8/6/09
to
Steve wrote:
>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

--
Marsh

Steve

unread,
Aug 6, 2009, 8:58:41 PM8/6/09
to
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" <marsh...@wowway.com> wrote in message
news:u2em7558h2ivqu2ej...@4ax.com...

Marshall Barton

unread,
Aug 6, 2009, 11:24:05 PM8/6/09
to
Steve wrote:
>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.

--
Marsh

pinkpanther

unread,
Sep 10, 2009, 11:20:16 PM9/10/09
to
On Aug 6, 8:58 pm, "Steve" <notmyem...@address.com> wrote:
> 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


ton...@gmail.com

unread,
Dec 3, 2014, 12:15:41 PM12/3/14
to
Hi Marsh,

Please could you provide some screenshots. The first page gives me a -XX, then subsequent pages are correct. example I have produced a stock take card showing 91 items in total, there are 17 items per page. The first page shows -74 (91-74 = 17), then pages 2,3 and so on show number of items per page = 17, last page shows 6 items which is reported correctly. How do I get page one showing correctly?

Regards,
Tony

This is the code I have used:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then curTotal = curTotal + Me.txtDtlCnt
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
'Static lngPrevCnt As Long
Me.PageTotal = Me.txtDtlCnt - lngPrevCnt
lngPrevCnt = Me.txtDtlCnt
End Sub

Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
lngPrevCnt = 0
End Sub

Patrick Finucane

unread,
Dec 3, 2014, 1:43:00 PM12/3/14
to
Did it take 5 years for your post to arrive?
0 new messages