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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display counts in page footer

How To

Display counts in page footer

by  randysmid  Posted    (Edited  )
Hello everyone,
For some reason, it isn't all that easy to count records printed on a page, and display that count inside the page footer. Here is a technique that works for me:

1) Place a textbox in the footer, and call it txtPageCount. Be sure to set the Format property to standard, or some other numeric type. Modify the label, e.g., "Page Counts: ".

2) Click on the Report Properties button (which is located to the left of the horizontal ruler, and just below the toolbars). Click on the Event tab, then click on "On Open". Click the 3 dots at the end of the line, then select Code Builder.

3) Go up to the listbox that contains the word "Report", and click on the arrow. Select "(General)". The right listbox should now show "Declarations". Enter this code:
Public intPageCount As Integer
'"Public" variables stay alive until the report finishes

4) Scroll back down to "Private Sub Report_Open..." and paste this code in to the procedure:
' the following code initializes the variable
intPageCount = 0

5) Go back to listbox that contains the word "Report", and select "Detail", then select "Print" in the righthand listbox. Enter the following code:
' increment intPageCount for each record printed
intPageCount = intPageCount + 1

6) Go back to the listbox and select "PageFooterSection", and select "Format" in the righthand listbox. Insert this code:
'set the textbox in the footer to intPageCount
txtPageCount = intPageCount
'reset our counter (intPageCount)
intPageCount = 0

That's it!!!

Feedback, comments?
Randy Smith, MCP
rsmith@cta.org [pc2]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top