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

Counting Records

Status
Not open for further replies.

Monguse

Programmer
Mar 11, 2002
63
US
Can anyone give me some help on how to count the number of records in an Access Table?
I am rewritting the search routines and need to know the total number of records in order to do the search faster.

Thanks "The beauty of the second amendment is, that it will not be needed until they try to take it." - Thomas Jefferson

WebMaster:
 
what kind of DB connection are you using. Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
Sorry I did forget to say, I am using ADO and the Access Table is indexed. "The beauty of the second amendment is, that it will not be needed until they try to take it." - Thomas Jefferson

WebMaster:
 
try this

select count(MyTable.CustomerID) as CountCustID
From MyTable

Sam
 
If you have all the records in an ADO recordest, it's as simple as (if rs is the Recordset name):
[tt]
rs.RecordCount
[/tt] Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
But to get an accurate count do a rs.MoveLast
Also, RecordCount will not work on ForwardOnly or Dynamic cursors.

If you end up using Select Count then do not reference a field and it will be faster:
SELECT COUNT(*) FROM myTable

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top