Counting records of certain types with DAO
Iv been trying to find a way to count records that match a certain criteria, iv been usimg loops which are very slow for large record sets.... is there a cammand that can help me do this? this is the code i use to connect to teh database.
Code:
Public dbEmc As Database
Public rsEmc As Recordset
Set dbEmc = OpenDatabase("DB\EMC.mdb")
I can add and update records using .addnew and .edit/.update are there any other commands i can use? If there are any tutorials you can think of which may be releven i woul dbe greatful.
Kind Regards
PsYiOn
Re: Counting records of certain types with DAO
Are you sure your want to count records in a table.
In that case use following code
vb Code:
Dim x As Database
Dim y As Recordset
Set x = OpenDatabase("C:\tst.mdb")
MSgbox "total records count is" & x.TableDefs("tableName").RecordCount
Re: Counting records of certain types with DAO
Use the SQL COUNT - it is very easy. Check our Database FAQ section.