The BOF property on a Recordset object indicates that the current record position is before the first record in a Recordset object. This property returns a Boolean value.
IsBOF = recordset.BOF
The BOF property is used to determine whether a Recordset object contains records or whether you have gone beyond the limits of a Recordset object when you move from record to record.
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.
If the BOF property is True, there is no current record.
If a Recordset object is opened containing no records, both the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is zero. When a Recordset object is opened that contains at least one record, the first record is the current record and the BOF and EOF properties are False.
If the last remaining record in the Recordset object is deleted, the BOF and EOF properties may remain False until you attempt to reposition the current record.
This table below indicates 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 |
Note that executing a Move 0 method when the BOF property is True does not currently generate an error using the OLE DB Provider for AS/400 and VSAM.
Allowing a Move method does not guarantee that the method will successfully locate a record; it only means that calling the specified Move method will not generate an error.
The following table shows what happens to the BOF and EOF property settings when various Move methods are called but are unable to successfully locate a record.
BOF property | EOF property | |
---|---|---|
MoveFirst MoveLast |
Set to True | Set to True |
Move 0 | No change | No change |
MovePrevious Move < 0 |
Set to True | No change |
MoveNext Move > 0 |
No change | Set to True |