Counting records

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
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top