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

Display Record Count Before Printing Report 2

Status
Not open for further replies.

slocat

Programmer
Jun 18, 2001
12
0
0
US
I have created several reports where it would be useful to know how many records are included in the report before printing. For example, it would be nice to know how many labels will be printed before loading the printer. I am trying to create a popup form that displays the record count when the print button is clicked. I've created a form, but I can't get it to show the record count. I'd appreciate any suggestions on how to do this!
 
Use a dcount function on the table/query which is the report's recordsource and pop it into a msgbox before you call the report.

For example:

Dim NumRecs as integer

NumRecs = Dcount("*","table query name here","any criteria here")
msgbox "There are " & NumRecs & " items in report."
docmd.openreport "reportname",acViewNormal,,"any criteria" Maq B-)
<insert witty signature here>
 
Thank you, Maq! That was just what I needed and much simpler than the code I was fumbling around with.

Slocat
 
Put the code in the click event of the button that calls the report. Maq B-)
<insert witty signature here>
 
Well, in my case, I don't have a button that calls the report. I just need have a table, a query, a report, and a song in my heart.

Would I put the code in the Open Event of the report itself?

Instead of a message box, I need to insert the record count in the report itself.

I understand what the code does, I'm just not sure where to put it and how to activate it. For example, once the NumRecs variable is defined, how do I insert the value into the report?

Thanks,
 
Oh, well in that case just put an extra textbox in your report footer and set the control source to:

=Count([someuniquefieldperrecord]) Maq B-)
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top