Creating a Recordset

You can create a recordset by using the OpenRecordset method of the Database, TableDef, or QueryDef objects:

Set rst = dbs.OpenRecordset( Source, Type, Options, LockEdits ) Set rst = object.OpenRecordset( Type, Options, LockEdits )

The Source argument specifies the name of a table or query, or a string expression that equates to an SQL query. For recordsets opened using the dbOpenTable type argument, the Source argument can only be the name of a table.

The default recordset type that is opened if you omit the Type argument, depends on the type of table you're trying to open. If you open a Microsoft Access recordset on a local table, the default is a Table type. If you open a Microsoft Access recordset against a linked table or query, the default type is dynaset.

The Type argument values are specified by a number of constants. These constants and their values can be found in Appendix D. The following code examples demonstrate how to open different types of recordsets.

0 0

Post a comment