Limits of a Recordset

Applies to: Access 2013, Office 2013

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. Think of BOF and EOF as "phantom" records that are positioned at the beginning and end of the Recordset. Building on the sample Recordset from Examining Data, it would now look like this:

ProductID

ProductName

UnitPrice

BOF



7

Uncle Bob's Organic Dried Pears

30.0000

14

Tofu

23.2500

28

Rssle Sauerkraut

45.6000

51

Manjimup Dried Apples

53.0000

74

Longlife Tofu

10.0000

EOF



The BOF property returns True (-1) if the current record position is before the first record and 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 False if the current record position is on or before the last record.

If either the BOF or EOF property is True, there is no current record, as shown in the following code:

 
If oRs.BOF And oRs.EOF Then 
 ' Command returned no records. 
End If 

If you open a Recordset object containing no records, the BOF and EOF properties are both set to True and the value of the Recordset object's RecordCount property setting depends on the cursor type. -1 will be returned for dynamic cursors (CursorType = adOpenDynamic) and 0 will be returned for other cursors.

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 cursor is left in an indeterminate state. The BOF and EOF properties may remain False until you attempt to reposition the current record, depending upon the provider.