QueryDef.OpenRecordset Method

Access Developer Reference

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression.OpenRecordset(Type, Options, LockEdit)

expression   A variable that represents a QueryDef object.

Parameters

Name Required/Optional Data Type Description
Type Optional Variant A RecordsetTypeEnum constant that indicates the type of Recordset to open.
Bb243091.vs_note(en-us,office.12).gif  Note
If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.
Bb243091.vs_note(en-us,office.12).gif  Note
If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.
Options Optional Variant A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.
Bb243091.vs_note(en-us,office.12).gif  Note
The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.
Bb243091.vs_note(en-us,office.12).gif  Note
The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.
LockEdit Optional Variant A LockTypeEnum constant that determines the locking for the Recordset.
Bb243091.vs_note(en-us,office.12).gif  Note
You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.
Bb243091.vs_note(en-us,office.12).gif  Note
You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value
Recordset

Remarks

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Bb243091.vs_note(en-us,office.12).gif  Note
If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.