Scrolling and Retrieving Rows
An application can use the MoveFirst, MoveLast, MoveNext, and MovePrevious methods to scroll through a recordset to retrieve rows. Use the MoveFirst method to move the current record position to the first record in the Recordset. Use the MoveLast method to move the current record position to the last record in the Recordset.
Use the MoveNext method to move the current record position one record forward. If the last record is the current record and you call the MoveNext method, ADO sets the current record to the position after the last record in the Recordset and sets the EOF property to True. An attempt to move forward when the EOF property is set to True generates an error.
Use the MovePrevious method to move the current record position one record backward. If the first record is the current record and you call the MovePrevious method, ADO sets the current record to the position before the first record in the Recordset and sets the BOF property to True. An attempt to move backward when the BOF property is set to True generates an error.
If the Recordset object does not support backward cursor movement, a call to the MoveFirst or MovePrevious methods generates an error. For example, the default setting of the CursorType property is adOpenForwardOnly, which supports only the MoveLast and MoveNext methods.
Determining Recordset Limits
An application can use the BOF and EOF properties 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. By testing the values of the BOF and EOF properties, an application can avoid generating an error by using the MoveFirst, MoveLast, MoveNext and MovePrevious methods.
The BOF property returns True (-1) if the current record position is before the first record, and returns False (0) 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 returns False if the current record position is on or before the last record. If the BOF and EOF properties both are set to True, there is no current record. In this situation, the RecordCount property is set to zero.
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.