Moving Through a Recordset
All recordsets have a current position (pointed to by the current record pointer) and a current record. Normally, the current record is the record at the current position. However, there are two exceptions. The current position can be:
Before the first record
After the last record
in which cases there is no current record.
To change the current position (and hence the current record), Jet provides several Move methods:
MoveFirst moves to the first record.
MoveLast moves to the last record.
MoveNext moves to the next record.
MovePrevious moves to the previous record.
Move[n] moves forward or backward n positions.
In each case the syntax has the form:
RecordSetVar.MoveCommand
BOF and EOF
The properties BOF (Beginning of File) and EOF (End of File) are set by Jet after each move command. The concepts of BOF, EOF, current record, and current position can be confusing. Perhaps the following notes will help.
Notes on the BOF and EOF properties
BOF is
True
when the current position is before the first record in the recordset, not at the first record.EOF is
True
when the current position is after the last record in the recordset, not at the last record.If either of BOF or EOF is
True
, then there is no current record.If you open a recordset containing no records, then BOF and EOF are set to
True
. If the recordset has some records, then Jet does a tacit MoveFirst, so the first record becomes the current record and both BOF and EOF are set toFalse
.If you delete the ...
Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.