Count total # of records

BartK

Registered User.
Local time
Yesterday, 16:10
Joined
Jun 7, 2013
Messages
115
Simple question, I am wanting to display in a text box or on my report the total number or records in my database. Also I have some buttons that filter the results a little, I'm wanting to display the number after I hit the button(s). Would I just add the query to the end of each button I have?

Thanks
 
You can use Dcount("*", "theTableName") for getting the total number of records in theTableName.

If the Buttons are filtering out the reposrt dynamically then you might need to use the DCount with a criteria..
 
Each DCount requires another hit on the database. This may be able to be avoided.

If the number of records is based on the records in the Report, the Count function can be used as part of expression as the ControlSource of a textbox in the footer to return the number of records in the form's recordset.
 
Having a little bit getting it up and running. When I try to execute the report it asks me for Violation Data as well as criteria. I've tried deleting criteria, still no luck. Here is what I have done. On my report I've made a text box and the control source of the text box is as follows:

=DCount([Location],[Violation Data],[criteria])

I just picked location as the field. I don't really care what field I am counting I would like the number of records in the DB. Violation Data is the table name and as for the criteria. I don't really have any criteria, just like to get the number posted in the Text Box. Thoughts?
 
Last edited:
On my report I've made a text box and the control source of the text box is as follows:

=DCount([Location],[Violation Data],[criteria])

I just picked location as the field. I don't really care what field I am counting I would like the number of records in the DB.

DCount on a field will only return the count of records that are not null in that field. It is relatively slow because it must check every record for Null.

Use "*" as the expression argument to count the records without testing for Nulls.
 
Here is what I have put in
=DCount(
[*],[violation data],[criteria])
tried both "*" and as you see it, also have removed criteria from the end. Here is how it happens step by step.

Input my range of dates upon hitting switchboard button, then asks me for parameter value on both "*" as well as violation data. After that I can look at my report where my text box is it gives me #error.

Thanks for the help guys. It's actually the count function. Works beautifully. Thanks for all the help.
 
Last edited:
All Domain aggregate function have strings as their arguments.

=DCount("*", "[violation data]")
 

Users who are viewing this thread

Back
Top Bottom