Microsoft Office Tutorials and References
In Depth Information
Table 23-8. Key Properties and Methods of the Recordset Object
Method: moves the current record pointer to the next row in the
Method: moves the current record pointer to the previous row in
Method: gains access to the data in the Recordset .
Property: contains the total number of rows retrieved from the
Property: contains the list of column names on which the results
should be sorted.
Property: contains either an object reference to a Command object
or a string with an SQL statement.
Method: saves any changes you might have made to the current
row to the database.
The ActiveConnection property points either to the Connection object associated with Recordset ,
or it contains a connection string value. If the property contains a connection string, a con
nection to the database will be automatically opened when the Recordset object is opened.
The Source property contains either an object reference to a Command object or a string con
taining the name of a table, a stored procedure or an SQL statement. If you assign a Command
object to the source property, reading the source property will return the CommandText
value from the Command object rather than an object reference.
Once you’ve set up all the information that you need to retrieve data from the database, use
the Open method to gain access to the information in the Recordset object. When you are
through with the data, use the Close method to release all the resources associated with the
The Recordset object exposes the returned records from the database one row at a time.
Internally, the Recordset object maintains a pointer referred to as the current record pointer ,
which points to the current record.
Because only one record is available at a time, you must use the move methods ( MoveFirst ,
MovePrevious , MoveNext , and MoveLast ) to navigate your way through the records in the
Recordset . The Move method allows you to jump forward or backward in the record the
specified number of rows.
As you move through the records in the Recordset , the BOF and EOF properties will automat
ically be set as the current record pointer changes. BOF stands for Beginning Of File , and
EOF stands for End Of File . The best way to think of these two properties is that they
represent locations before the first row in the Recordset BOF ) and after the last row in the (
Recordset EOF ). (