It is the property of Recordset object. The RecordsetObject.BOF is used to check the following conditions:
- If the Recordset object does not contain the record, the RecordsetObject.BOF is set to True.
- If the position of the current record is on the left of the first record, the RecordsetObject.BOF is set True too.
This property is used to check the following conditions:
- If Recordset object does not contain the record, the RecordsetObject.EOF property will take True.
- If the location of the current record beyond the position of the last record, the RecordsetObject.EOF property will take True also.
TheRecordsetObject.RecordCount property is used count the number of records in the Recordset object.
This property is use for the following terms:
- Display the position of the current record in the Recordset object.
- Define the location of the current record in the Recordset object.
This example will demonstrate the using of the Recordset object's properties including BOF, EOF and AbsolutePosition. For example, you have the DisplayData form as figure:
- When you click the Read Data command button, the first record was displayed in the CategoryID and CategoryName text boxes. In addition, the message box dialog will display this first record with its position. Then it will display the next record until the last record with each its position. While each record displays on the message box, it also displays in the two text boxes. Look at the figure below:
The VBA code below fulfills the conditions above:
Option Compare Database
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Private Sub Form_Load()
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("TblCategory", dbOpenDynaset)
Private Sub CmdReadData_Click()
If Rs.BOF = True Then
MsgBox "The table does not have a record"
While Not Rs.EOF
txtCateID.Value = Rs(0)
txtCateName.Value = Rs(1)
MsgBox Rs(0) & " " & Rs(1) & vbCrLf & "The position of the Record is:" & " " & Rs.AbsolutePosition + 1
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: