ADO BOF and EOF Properties
The BOF and EOF properties return Boolean values. 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.
The BOF property returns True (-1) if the current record position is
before the first record in the Recordset, otherwise it returns False
(0).
The EOF property returns True (-1) if the current record position is
after the last record in the Recordset, otherwise it returns False (0).
Note: The BOF and EOF properties are set to True if you open an empty
Recordset. In another word, if either the BOF or EOF property is True,
there is no current record. RecordCount property is zero.
Note: If 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.
Note: 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.
Syntax
objRecordset.BOF
or
objRecordset.EOF |
Example
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim x As Object
set conn=New ADODB.Connection
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "F:\Mydata\northwind.mdb"
set rs = New ADODB.recordset
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
While rs. EOF =false
For each x in rs.Fields
debug.print(x.value)
Next
rs.MoveNext
Wend
rs.close
conn.close
Set rs = Nothing
Set conn = Nothing
OR
......
If (rs. BOF =True) Then
rs.MoveFirst
End If
......
|
|