In ADO (ActiveX Data Objects), the BOF and EOF properties are used to determine whether the current record position in a Recordset object is before the first record or after the last record.
1. BOF (Beginning of File)
2. EOF (End of File)
3. Common Usage Example
In ADO, it’s common to check for both properties before processing records:
Set rs = conn.Execute("SELECT * FROM Employees")
If rs.BOF And rs.EOF Then
MsgBox "No records found!"
Else
rs.MoveFirst
Do Until rs.EOF
MsgBox rs("EmployeeName")
rs.MoveNext
Loop
End If
4. Key Points
-
BOF and EOF are Boolean properties (True or False).
-
Both are True when the Recordset is empty.
-
You typically check If rs.EOF in loops to detect when you’ve reached the end of records.
-
Moving before the first or after the last record sets these flags to True.