Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting records on a page in report 1

Status
Not open for further replies.

MtMtn

Technical User
Jul 26, 2006
7
US
this seems simple but I can't get it. I have a report that is 20 pages long and I want to count the records on each page and have that count show up at the bottom of the page. ie: if the page contains 25 records - then the footer would contain "There are "x" units on this page". Therefor if I change the font size or format the number of records will change and the count will reflect that.
 
You could try adding a hidden running sum to the detail section that will give a line number (Over All), called, say, txtLine. Add a textbox to the page footer called, say, txtNoLines, then add a little code:
Code:
'Module level
Dim ln

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
Me.txtNoLines = Me.txtLine - Nz(ln, 0) + 1
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
ln = Me.txtLine
End Sub
 
Forgive my ignorance, but I'm not sure how to create a running sum to give a line number and then I'm not sure where to add the code. Does it go in the control source box or there another place that I should put it?
 
No problem. Add a text box to the detail section of your report. Set these properties.

[tt]Name : txtLine
ControlSource : =1
Visible : False
Running Sum : Over All[/tt]

You will find these properties on the All tab of the properties sheet in the above order.

As for the code, choose View->Code from the menu or click the code button on the toolbar and cut and paste the code above into the window. Check the properties for the page footer and page header (double-click the grey bars to bring up the properties sheet or single click, if the properties sheet is open) to make sure that the On Format event (Event tab) is set to [Event Procedure]. Make sure you have added a textbox (descibed above) to the page footer. Put it all on to cook. :)


 
Thanks, I think I'm getting closer. When I try to preview I get a popup box that states -
"The expression On Format you entered as the event property setting produced the following error: Ambuguous name detected: PageFooterSection_Format."

With the text box in the page footer called "txtNoLines" - is there a control source and is there a running sum or am I missing something else?
 
Thank you Remou. I had to many lines in the code and now it works. You are the master!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top