Total Number of records

St. Ungland

New member
Local time
Today, 05:28
Joined
Apr 6, 2002
Messages
6
Hi, I want to add up the total number of records and store it as a separate field, for later use in a report, however my knowledge of VBA is very limited. I'm using Access 2000 and any help would be greatly appreciated!!
 
Even without VBA you can get the total but I don't understand why you'd want to store this total in a table - it should be possible to count by using the DCount() aggregate function on your report with the expression counting the number of records in the query you are basing your report on.
 
I use
Dim r as Integer

Me.RecordsetClone.MoveLast
r = Me.Recordset.RecordCount

msgbox r

The msgbox will display the No of records.

If you declare the r in a module it can be referenced from any form or report

Use: Public r as Integer

PS It doesn't have to r, it can be almost anything as long as it is unique

HTH
Dave
 
You could also just put =Count(*) on the form/report, which is more efficient than both methods previously suggested, assuming you just want a count from the underlying recordset
 
Rich - You would put =Count(*) in an ubound text box I presume.
Things you learn here:)
As has been mentioned many many times, the newer the version of access, the worse the help files are!
Dave
 

Users who are viewing this thread

Back
Top Bottom