7.6. Creating ADO Recordsets

Both ADO and DAO provide Recordset objects, which are commonly used in code. In fact, many of the code samples in this chapter use recordsets. However, up to now, the recordset has been assigned a value based on the records returned as the result of executing an action.

Using the ADO Recordset object, you can implicitly execute an action by calling the Open method for the Recordset. Open retrieves the records from a data source based on the criteria and stores them in the Recordset object. It has five parameters, all of which are optional. The following table describes each of those parameters.

ParameterDescription
SourceOptional. The Source argument can be a SQL statement, the name of a table, the name of a stored procedure, a URL, or a provider-specific text or command.
ConnectionStringOptional. The ConnectionString argument can be a Connection object or a Connection string.
CursorTypeOptional. Specifies the type of cursor to use for the Recordset.
LockTypeOptional. Specifies the type of lock to use for the Recordset.
OptionsOptional. Specifies the command option(s) to use for the Recordset.

Appendix F contains a list of all the available CursorType, LockType, and Options members and a description of those members. You can supply more than one Options value by using the Or operator; for example:

rs.Options = adCmdStoredProc Or adAsyncFetchNonBlocking

7.6.1. Creating a Recordset from a Command Object

Suppose you need to create a recordset that is based ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.