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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.