Counting records

  • Thread starter Thread starter dpdeleon
  • Start date Start date
D

dpdeleon

I need to get a record count for a recordset. Should I use a select count(*)
statement or select all of the records and then use the recordCount
property?

Thanks
 
dpdeleon said:
I need to get a record count for a recordset. Should I use a select
count(*) statement or select all of the records and then use the
recordCount property?

You've already opened the recordset, so you have a recordset object to
work with? Then you may as well do:

With rs
.MoveLast
YourCountVariable = .RecordCount
.MoveFirst ' if you plan to loop through the records
' ... do whatever else you want with rs ...
.Close
End With

If you don't need to process the records, but just want to know how many
records there are, then you're better off opening a recordset on a
"SELECT COUNT(*)" query.
 
Back
Top