BOF returns a value that indicates whether the current record position is before the first record in a Recordset object.
EOF returns a value that indicates whether the current record position is after the last record in a Recordset object.
The return values for the BOF and EOF properties are Boolean values.
The BOF property returns True if the current record position is before the first record, and False if the current record position is on or after the first record.
The EOF property returns True if the current record position is after the last record, and False if the current record position is on or before the last record.
You can use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.
If either the BOF or EOF property is True, there is no current record.
If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is 0. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False.
If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.
This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.
MoveFirst, MoveLast |
MovePrevious,Move < 0 | Move 0 | MoveNext, Move > 0 |
|
---|---|---|---|---|
BOF=True, EOF=False |
Allowed | Error | Error | Allowed |
BOF=False, EOF=True |
Allowed | Allowed | Error | Error |
Both True | Error | Error | Error | Error |
Both False | Allowed | Allowed | Allowed | Allowed |
Allowing a Move method doesn't mean that the method will successfully locate a record. It only means that calling the specified Move method won't generate an error.
Calling the Delete method, even if it removes the only remaining record from a Recordset, won't change the setting of the BOF or EOF property.
The following table shows what happens to the BOF and EOF property settings when you call various Move methods, but are unable to successfully relocate a record.
BOF | EOF | |
---|---|---|
MoveFirst, MoveLast | True | True |
Move 0 | No change | No change |
MovePrevious, Move < 0 | True | No change |
MoveNext, Move > 0 | No change | True |