OpenRecordset Method Example (MDB)
The following example opens a dynaset-type Recordset object and prints the number of records in the Recordset object.
Sub UKOrders()
Dim dbs As Database, rst As Recordset
Dim strSQL As String
' Return reference to current database.
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE [ShipCountry] = 'UK'"
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveLast
Debug.Print rst.RecordCount
rst.Close
Set dbs = Nothing
End Sub