RecordCount Property Example (MDB)

The following example creates a Recordset object based on the Orders table and then determines the number of records in the Recordset object:

Sub CountRecords()
    Dim dbs As Database, rst As Recordset

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Open table-type Recordset object.
    Set rst = dbs.OpenRecordset("Orders")
    Debug.Print rst.RecordCount
    rst.Close
    Set dbs = Nothing
End Sub