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

Access Table record Count

Status
Not open for further replies.

zggs90

Programmer
Sep 3, 2001
58
0
0
GB
I recently saw a technique for determining the number of records in an Access table without having to read the table. This was using something like "systable" or "table " properties, but of course I forgot to make a note of it.

it was a statement like :

recordcount = "Table Name ".records

can anyone guide me to the correct codeing?

Regards

Geoff
 
This does it...

Sub mRecordCount()
Dim db As Database
Dim rst As Recordset
Dim intRecordCount As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("tblQuestion", dbOpenSnapshot)

rst.MoveLast
intRecordCount = rst.RecordCount

rst.Close

Set rst = Nothing

End Sub
 
The DCount function is good for this. It works without defining a recordset. It also lets you count based on criteria. MoveLast can be quite slow if you have lots of records. Frank
 
To reiterate what someone already said, heres the one line function:

recordCount = DCOUNT("*", "tableName")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top