BOF, EOF Properties Example (MDB)

The following example uses the EOF property of a Recordset object to move the current record pointer past the last record in the Recordset object, then uses the BOF property to move the current record pointer to before the first record in the Recordset object.

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

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Open recordset on Orders table.
    Set rst = dbs.OpenRecordset("Orders")
    ' Do until end of file.
    Do Until rst.EOF
        ' Move to next record.
        rst.MoveNext
        .
        .
        .
    Loop
    ' Move to last record to set a current record.
    rst.MoveLast
    ' Do until beginning of file.
    Do Until rst.BOF
        rst.MovePrevious
        .
        .
        .
    Loop
    rst.Close
    Set dbs = Nothing
End Sub