Count number of records on a report page

G

Guest

Hi All,

My report has several grouping levels and works OK. I am OK with creating a
text box to count the entire number of records in a report and in a group.

But I've been asked to count the number of records printed on any given
report page. How can I do this?

I'm using version 2003.

Thanks in advance
 
J

John Spencer

TRY this.
Add a control to the detail line to number the detail lines
Name: txtLineCount
Control Source: =1
Running Sum: OverAll

Add a control to the page header
Name: txtPageStart
Control Source: =[txtLineCount]

Add a control to the page footer
Name: txtRecCount
Control Source: BLANK

Add the following code events
Page Header Format Event
Page Footer Format Event

'Code for the events

Option Compare Database
Option Explicit
Dim lngPageBegin As Long 'Variable to hold current page

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.txtRecCount = 1 + Me.txtLineCount - lngPageBegin
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
lngPageBegin = Me.txtPageStart
End Sub



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

John Spencer

If the detail splits over two pages it will be counted as a record on each
page.

That is if you print record 1 to 3 and part of 4 on page 1 and the remainder
of 4 on page 2 along with records 5 to 9 then you will get counts like:
Page 1: 4 (1 to 4)
Page 2: 6 (4 to 9)


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

John Spencer said:
TRY this.
Add a control to the detail line to number the detail lines
Name: txtLineCount
Control Source: =1
Running Sum: OverAll

Add a control to the page header
Name: txtPageStart
Control Source: =[txtLineCount]

Add a control to the page footer
Name: txtRecCount
Control Source: BLANK

Add the following code events
Page Header Format Event
Page Footer Format Event

'Code for the events

Option Compare Database
Option Explicit
Dim lngPageBegin As Long 'Variable to hold current page

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.txtRecCount = 1 + Me.txtLineCount - lngPageBegin
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
lngPageBegin = Me.txtPageStart
End Sub



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

DeDe said:
Hi All,

My report has several grouping levels and works OK. I am OK with
creating a
text box to count the entire number of records in a report and in a
group.

But I've been asked to count the number of records printed on any given
report page. How can I do this?

I'm using version 2003.

Thanks in advance
 

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