O'Reilly logo

Access™ 2007 VBA Programmer's Reference by Armen Stein, Geoffrey Griffith, Rob Cooper, Teresa Hennig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required