<> </P> " m/ D) a9 I! U. _<>Creates a new Recordset object and appends it to the Recordsets collection. </P>" B; E4 x% t9 c
<> </P>4 k+ y' l( d+ g# T' M& F( r
<>Syntax </P>3 x4 X7 u0 k+ k3 e6 j& ?
<> </P> - o2 _- r: K+ ^5 x- t- ^: I<>For Connection and Database objects: </P> 8 u* d- b9 P% [& x3 X# }/ S<> </P>1 C' Y' P9 Q8 l* d
<>Set recordset = object.OpenRecordset (source, type, options, lockedits) </P>! c5 X& X6 H& X
<> </P>8 U6 S5 y* U: q6 D7 Q
<>For QueryDef, Recordset, and TableDef objects: </P> $ \, V7 u' m- V) c7 F4 k<> </P>% C0 H7 |3 d, u% ]
<>Set recordset = object.OpenRecordset (type, options, lockedits) </P>0 F1 [. p' R0 x; r% ^: v
<> </P> / V1 g4 u/ q& W0 f* M) b1 Z; y<>The OpenRecordset method syntax has these parts. </P> * E8 b* k4 E& V5 I<> </P> 8 Q: ]# g" J+ s! T<>art Description </P>) V, ~) S/ s* U1 Q/ Z! ~, A" y8 B
<>recordset An object variable that represents the Recordset object you wantt to </P>1 O L. G, c4 n4 j K- o3 O
<>open. </P> ! F- ?) Y( O! K<>object An object variable that represents an existing object from which you </P>; i* m! ]/ U4 A& x% @, a- H! W& `
<>want to create the new Recordset. </P> $ V- x* H9 J+ V- ]0 q2 I' R1 o. D<>source A String specifying the source of the records for the new Recordset. </P>2 v& P j+ H3 `: `* p( r- q5 o; Z
<>The source can be a table name, a query name, or an SQL statement that </P> ' c6 o6 i9 {5 W( k7 ?<>returns records. For table-type Recordset objects in Microsoft Jet databases, </P> 8 V. R, d. v0 K8 I8 t# P<>the source can only be a table name. </P>/ r! p: `3 F5 `# Y4 `- k% Z
<>type Optional. A constant that indicates the type of Recordset to open, as </P>6 s$ A: F# x% c
<>specified in Settings. </P> 4 |4 B( \: @: ]1 p<>options Optional. A combination of constants that specify characteristics of </P> # x' E; U \/ h# ^, u3 y0 b( K<>the new Recordset, as listed in Settings. </P> # W) [8 T& \) D4 ~ }. C8 p<>lockedits Optional. A constant that determines the locking for the Recordsset, </P>' s4 Z4 G3 Z( f6 T; T& V. t
<P>as specified in Settings. </P> m( Z. H; m) [7 m+ C/ o+ J
<P>Settings </P>3 t9 K) _, P( Q. _) h* u
<P> </P>3 V* Q+ l) T4 o6 o; Q9 U
<P>You can use one of the following constants for the type argument. </P> # G: c) ]# O$ r; y9 P: @<P> </P>/ n% G7 H, t% `0 ~: ^# e$ [
<P>Constant Description </P>* v. G+ @$ E* ~
<P> </P> ( y' T7 T- [% h/ L5 x<P> </P>2 P. H, [+ k o! y: C
<P>dbOpenTable Opens a table-type Recordset object (Microsoft Jet workspaces </P>; u6 d0 p/ E# {# _! _( b9 S
<P>only). </P>. P# \: k; G& Q0 C- p8 Z, e U- B
<P>dbOpenDynamic Opens a dynamic-type Recordset object, which is similar to an </P>. d7 N* P" q& p4 h8 H# T4 j
<P>ODBC dynamic cursor. (ODBCDirect workspaces only) </P> " B# [! h; [# A<P>dbOpenDynaset Opens a dynaset-type Recordset object, which is similar to an </P> # H7 F8 e& h8 T; i<P>ODBC keyset cursor. </P>- V& U0 N4 q: z
<P>dbOpenSnapshot Opens a snapshot-type Recordset object, which is similar to an </P>, ~! t7 Y! W/ Z7 }$ Y8 `
<P>ODBC static cursor. </P># x+ z6 X1 W! a( |1 O2 ^ |1 {
<P>dbOpenForwardOnly?Opens a forward-only-type Recordset object. </P>; j& S. j2 K9 v0 F0 n* P! o' t
<P>Note If you open a Recordset in a Microsoft Jet workspace and you don't </P>0 k* P8 w& B Y- U. d
<P>specify a type, OpenRecordset creates a table-type Recordset, if possible. If </P> ) a8 F3 O5 d) F9 ?- f<P>you specify a linked table or query, OpenRecordset creates a dynaset-type </P>1 E) K1 x' \3 D
<P>Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnl </P>* m' h9 C T( R' q: J9 a1 f
<P>y. </P>& {/ K& z, \$ e3 V) h. r
<P> </P> 2 T. w& q7 ?" m: S! y<P>You can use a combination of the following constants for the options </P>8 c3 p) L7 B) R' e! k
<P>argument. </P> # D; z w: G) l* H. R0 s- H! @9 u. I5 q<P> </P>4 j' I$ N" v5 L/ }2 J) r3 G
<P>Constant Description </P> 3 o- f5 e: g* @1 \$ }) f<P>dbAppendOnly?Allows users to append new records to the Recordset, but </P> - ~, B& C# j( P" F/ S& ?7 q& X$ i<P>prevents them from editing or deleting existing records (Microsoft Jet </P>& w4 b+ V9 N: C d0 Y; w
<P>dynaset-type Recordset only). </P> / @. C/ b3 u) E& Q<P>dbSQLPassThrough?Passes an SQL statement to a Microsoft Jet-connected ODBC </P>* L5 C) J) G# x0 H9 y/ {& F
<P>data source for processing (Microsoft Jet snapshot-type Recordset only). </P> 6 |$ x6 V- E9 \+ O<P>dbSeeChanges Generates a run-time error if one user is changing data that </P>0 C, A1 U6 h& F) b9 d4 y
<P>another user is editing (Microsoft Jet dynaset-type Recordset only). This is </P> 3 E# t5 G+ |! O$ R# S/ f<P>useful in applications where multiple users have simultaneous read/write </P> % l& t$ I }0 i* x2 {<P>access to the same data. </P> 4 L* T/ P2 Z& E: u2 k9 b<P>dbDenyWrite?Prevents other users from modifying or adding records (Microsoft </P> 6 y* V) C/ r/ G* Q. O1 z<P>Jet Recordset objects only). </P>' e8 \. `) B3 Y, c) c
<P>dbDenyRead?Prevents other users from reading data in a table (Microsoft Jet </P> 5 i7 l4 j E' y& F: p% ^<P>table-type Recordset only). </P>+ n; k6 _7 C" N; N: f. x" o
<P>dbForwardOnly?Creates a forward-only Recordset (Microsoft Jet snapshot-type </P>4 J$ t! d* \; e* x' [* e
<P>Recordset only). It is provided only for backward compatibility, and you </P> B& z/ S Z- [2 V1 P5 C! V+ ^
<P>should use the dbOpenForwardOnly constant in the type argument instead of </P>5 @! I4 W- g1 n9 w I C
<P>using this option. </P> 7 z5 x+ @, ~) ?2 f$ g6 K' @1 o<P>dbReadOnly?Prevents users from making changes to the Recordset (Microsoft Jet </P> : H4 Y) _1 e: M<P>only). The dbReadOnly constant in the lockedits argument replaces this </P> , i* k2 e" `3 U9 e& J<P>option, which is provided only for backward compatibility. </P> % D4 o, k( N/ o6 a9 O& |( @4 T7 I<P>dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only). </P>' a v _. F5 I* o$ _. J
<P>dbExecDirect?Runs a query by skipping SQLPrepare and directly calling </P>* S' s/ d' z. F) K8 G! ^! D
<P>SQLExecDirect (ODBCDirect workspaces only). Use this option only when you抮e </P> , ]/ d( {4 M/ ~! }<P>not opening a Recordset based on a parameter query. For more information, see </P> $ Y. U! @2 d4 }+ t8 P<P>the "Microsoft ODBC 3.0 Programmer抯 Reference." </P> : s' i p+ T! |& u, X4 A<P>dbInconsistent?Allows inconsistent updates (Microsoft Jet dynaset-type and </P>% y) p" } t( o [5 Y1 v- Q# a
<P>snapshot-type Recordset objects only). </P> : N& a0 r# n3 R: e# G0 M2 V<P>dbConsistent?Allows only consistent updates (Microsoft Jet dynaset-type and </P> k8 l; x) {8 F; _2 ~, d
<P>snapshot-type Recordset objects only). </P>- ^* M8 e1 y4 D8 X
<P>Note The constants dbConsistent and dbInconsistent are mutually exclusive, </P> 0 A, T. n' i: R<P>and using both causes an error. Supplying a lockedits argument when options </P> 1 h8 [& Z- E( h3 Z- u# C$ p<P>uses the dbReadOnly constant also causes an error. </P> # ?( d7 `% ]8 t, b/ _<P> </P> # P& c: k; t$ \/ p7 q( E<P>You can use the following constants for the lockedits argument. </P> : Z* b/ e7 ~4 T/ z& l<P> </P> 4 t' j0 [3 Q* g6 h<P>Constant Description </P>( _! L" Y2 V- Q; ?- P( y8 x
<P>dbReadOnly Prevents users from making changes to the Recordset (default for </P> ; Q, _ S f+ P+ {/ x<P>ODBCDirect workspaces). You can use dbReadOnly in either the options argument </P>) r1 i! S. ?5 O" u+ w. ~
<P>or the lockedits argument, but not both. If you use it for both arguments, a </P>4 j7 T+ H2 [+ w; Y' E/ R% ~! w% T8 H
<P>run-time error occurs. </P>7 J; h4 o; G& y
<P>dbPessimistic?Uses pessimistic locking to determine how changes are made to </P>4 J# g% Y0 p* c: |6 P
<P>the Recordset in a multiuser environment. The page containing the record </P>) x8 ^4 d; C8 ~5 u; y
<P>you're editing is locked as soon as you use the Edit method (default for </P> e3 S- V% c2 a! e+ C6 T9 q<P>Microsoft Jet workspaces). </P>% W6 b! V/ j7 R/ y+ ~
<P>dbOptimistic?Uses optimistic locking to determine how changes are made to the </P>" a7 }: r- q" P9 w2 [; i$ A2 D4 `
<P>Recordset in a multiuser environment. The page containing the record is not </P>, L0 R: c6 L& }) T
<P>locked until the Update method is executed. </P> " H. x- q3 R8 p# O/ p- G6 x: X5 p/ d<P>dbOptimisticValue?Uses optimistic concurrency based on row values (ODBCDirect </P>+ w- S6 q+ ~: `( Y3 g4 E8 Q
<P>workspaces only). </P>" ~0 w6 I& x- U6 |8 [ C; _
<P>dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect workspaces </P>* H% K4 D: g& F) s
<P>only). </P> o3 ^7 V& U+ M( v- m* e! T- m
<P>Remarks </P>8 E5 N. I9 Q# W# e: n
<P> </P> ; ~- `* h2 \$ s0 Z) ~ p3 s<P>In a Microsoft Jet workspace, if object refers to a QueryDef object, or a </P>" w4 ]( K8 Z4 J8 c) `
<P>dynaset- or snapshot-type Recordset, or if source refers to an SQL statement </P>3 o+ Z% g: ?( q& `6 ~/ v
<P>or a TableDef that represents a linked table, you can't use dbOpenTable for </P>8 ^' s" y9 T, Y6 W
<P>the type argument; if you do, a run-time error occurs. If you want to use an </P>' z% b9 b. h( c$ D1 W1 X4 c6 d S
<P>SQL pass-through query on a linked table in a Microsoft Jet-connected ODBC </P>9 G$ j3 z- L" |. ?5 D
<P>data source, you must first set the Connect property of the linked table's </P>! c7 u& ]: y- I& R- ~
<P>database to a valid ODBC connection string. If you only need to make a single </P> : e5 O$ y) Y3 \% s3 k<P>pass through a Recordset opened from a Microsoft Jet-connected ODBC data </P>& u7 `8 k8 \' Q# F, `" z8 z
<P>source, you can improve performance by using dbOpenForwardOnly for the type </P> 6 ^2 J# ^- L2 b( Q6 }<P>argument. </P> : H' M' d8 s) D! D<P> </P>% b% p& E5 K! b% ?" y$ D
<P>If object refers to a dynaset- or snapshot-type Recordset, the new Recordset </P>! M9 H$ s; e* r9 f+ t# x# ^2 ~, a# |
<P>is of the same type object. If object </P> - g* c! D* E2 @7 M1 r! h8 Z/ m<P> refers to a table-type Recordset object, the type of the new object is a </P>2 M ~4 s* T, W( w& o/ A' }
<P>dynaset-type Recordset. You can't open new Recordset objects from forward-only </P>; F, V0 h& J3 X8 i' K1 J
<P>杢ype or ODBCDirect Recordset objects. </P>% i, y2 f" K- G% @
<P>In an ODBCDirect workspace, you can open a Recordset containing more than one </P> ) f3 |" O6 o3 S6 k$ F; i<P>select query in the source argument, such as </P>4 r* m% j7 Q' y! {, B
<P> </P> * ]) k- i; ]% o4 I& E! m4 k1 c<P>"SELECT LastName, FirstName FROM Authors </P> . D/ k: j& G' L1 |" o' o4 Z# C<P>WHERE LastName = 'Smith'; </P> 3 b/ p/ g8 m* l! q x<P>SELECT Title, ISBN FROM Titles </P> & ^- O' @1 ]7 ~! C0 P<P>WHERE ISBN Like '1-55615-*'" </P> 7 z) d1 p8 B M( q, ?<P> </P>1 P% h q& h' {: f5 [8 O/ k
<P>The returned Recordset will open with the results of the first query. To </P>2 j; S5 x$ E) Y; r: r
<P>obtain the result sets of records from subsequent queries, use the </P>. h. \: m7 {0 F
<P>NextRecordset method. </P> . g7 b, W9 U+ U7 u/ B- i" R<P> </P>* G5 w g( [0 [+ a. D2 X) I- ]! J
<P>Note You can send DAO queries to a variety of different database servers </P> - [- L4 E9 }" Y, l6 C. ~+ X1 ]2 ?' Q<P>with ODBCDirect, and different servers will recognize slightly different </P># L7 J9 _7 S& ]+ w& S
<P>dialects of SQL. Therefore, context-sensitive Help is no longer provided for </P> $ _0 |7 {- I; G! U9 u) A<P>Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still </P>8 u( l2 ^- I. q! v {& K
<P>included through the Help menu. Be sure to check the appropriate reference </P> 2 p F% e& j6 b' P- ^" `<P>documentation for the SQL dialect of your database server when using either </P> 1 d3 {3 V3 r+ F; N4 A<P>ODBCDirect connections or pass-through queries in Microsoft Jet-connected </P> 0 z0 V$ _2 L/ j2 t6 a<P>client/server applications. </P>4 ~8 z3 W! Z) F7 D# _, R b
<P> </P>4 z' v! ]* B% `# d0 `% l
<P>Use the dbSeeChanges constant in a Microsoft Jet workspace if you want to </P>% _ {# }' s& ]
<P>trap changes while two or more users are editing or deleting the same record. </P> 6 d/ ]+ t# [4 d<P>For example, if two users start editing the same record, the first user to </P> 6 `; I6 u; c2 l; k. m1 R<P>execute the Update method succeeds. When the second user invokes the Update </P> : _, O0 f$ ~' m- ^, D! U<P>method, a run-time error occurs. Similarly, if the second user tries to use </P> " Q' \# B9 o; j- o# ^: F F<P>the Delete method to delete the record, and the first user has already </P>: J/ } E" `; k0 M- n
<P>changed it, a run-time error occurs. </P>( D: d# }( w# `% g; v {
<P> </P>. N' X7 y6 p! t" X
<P>Typically, if the user gets this error while updating a record, your code </P>0 q5 y2 m- p/ V( P( B
<P>should refresh the contents of the fields and retrieve the newly modified </P> 6 N6 M8 B! M8 J. M1 M<P>values. If the error occurs while deleting a record, your code could display </P>, E* g" ?' t: C: h
<P>the new record data to the user and a message indicating that the data has </P>0 B0 Q3 ~! i" l" B* S6 M3 {
<P>recently changed. At this point, your code can request a confirmation that </P>5 x4 a9 f6 E) O' G0 J- }5 p
<P>the user still wants to delete the record. </P>3 A* h! F3 |3 Z3 @ {
<P> </P>* U$ D/ e* ?$ S4 I
<P>You should also use the dbSeeChanges constant if you open a Recordset in a </P> * u+ F- {. C0 S3 Y3 b6 n2 N4 v0 s; E: v1 O<P>Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server 6.0 (or </P>: @- K1 Z, L8 p* r+ |4 H: f+ ~" X
<P>later) table that has an IDENTITY column, otherwise an error may result. </P> ! ?8 \% x, V6 z3 S' x: h<P> </P>1 c+ r7 s4 @2 a4 S$ Q. V, x3 a
<P>In an ODBCDirect workspace, you can execute asynchronous queries by setting </P>% v% ^) S! u$ W9 o U5 J
<P>the dbRunAsync constant in the options argument. This allows your application </P>$ P0 \. |/ H% h! ^
<P>to continue processing other statements while the query runs in the </P> # h0 O8 t% \3 i2 j9 F# e<P>background. But, you cannot access the Recordset data until the query has </P>$ r, r/ u4 `; a2 T* \) u4 w, H0 t
<P>completed. To determine whether the query has finished executing, check the </P>% T: G) M }" b: f$ t% D# Y
<P>StillExecuting property of the new Recordset. If the query takes longer to </P>& t0 Y/ Z) d5 p
<P>complete than you anticipated, you can terminate execution of the query with </P>) F$ K1 j% p5 d: m6 Q5 N6 a$ [
<P>the Cancel method. </P> 9 `7 b4 M" n' A9 d t" q, v<P> </P> & O5 M8 G4 @. u6 h& `<P>Opening more than one Recordset on an ODBC data source may fail because the </P> ) M6 i: ]3 F; f3 I7 c! }9 k: @1 ^<P>connection is busy with a prior </P> " f) g9 B9 Y. S! T<P>OpenRecordset call. One way around this is to use a server-side cursor and </P> 5 W& `" c- P5 p4 a1 I8 l<P>ODBCDirect, if the server supports this. Another solution is to fully </P> $ ~$ F9 u: w: g8 Q: N<P>populate the Recordset by using the MoveLast method as soon as the Recordset </P>9 M) R, V2 i4 F
<P>is opened. </P>1 j: n2 t$ G4 n- m' R
<P> </P>! t: V. F" M v
<P>If you open a Connection object with DefaultCursorDriver set to </P>, J) k) e1 x( {
<P>dbUseClientBatchCursor, you can open a Recordset to cache changes to the data </P> * _4 @: [. w6 a% x<P>(known as batch updating) in an ODBCDirect workspace. Include dbOptimisticBatc </P> * T- ?5 \+ z L5 Z9 U<P>h in the lockedits argument to enable update caching. See the Update method </P>' U, W. a+ U) V) A" U
<P>topic for details about how to write changes to disk immediately, or to cache </P>3 \0 G J9 Z7 g! }- K
<P>changes and write them to disk as a batch. </P>6 L; |- f" P" s
<P> </P> 3 t* |9 b) ]1 v0 E<P>Closing a Recordset with the Close method automatically deletes it from the </P> 8 _; | X* Y* D9 ?; i: S/ H, ~# ~! M- X! a* {9 w
<P>Recordsets collection. </P> , S x* q, D* Z# @. P8 g<P> </P> ! R# L1 A, x. x( z9 t<P>Note If source refers to an SQL statement composed of a string concatenated </P>, A5 p; L8 X7 v$ {% D
<P>with a non-integer value, and the system parameters specify a non-U.S. </P># o: z$ U" n! Z" h8 B7 I# T* W
<P>decimal character such as a comma (for example, strSQL = "PRICE > " & </P> ; `5 Z3 @8 u6 ], @<P>lngPrice, and lngPrice = 125,50), an error occurs when you try to open the </P>& l( g; R4 G7 _8 j# S$ t
<P>Recordset. This is because during concatenation, the number will be converted </P> ! m! l# u, j/ V' Y' B% V6 N<P>to a string using your system's default decimal character, and SQL only </P> 7 N% L+ O5 Y" R1 n<P>accepts U.S. decimal characters.</P>