<> </P>8 M5 s. h' f% V% { ^
<>Creates a new Recordset object and appends it to the Recordsets collection. </P> ; W; f5 V# S- r: s# S$ K: E! x4 v) C<> </P>5 I- d3 u& w4 { ?
<>Syntax </P> 9 ~/ d: S$ ]7 Z# N( R! ?0 q<> </P> 1 U$ J' C- E! q/ [; D<>For Connection and Database objects: </P> ( Y8 Y' U1 n2 {( N- s<> </P>/ u: ?9 m* d8 j) L M% E0 H
<>Set recordset = object.OpenRecordset (source, type, options, lockedits) </P>1 g4 p7 c! q# V! `4 B8 S
<> </P>5 Y, r$ Y0 }9 A3 T( p$ g! c
<>For QueryDef, Recordset, and TableDef objects: </P>, D$ U5 ^& n6 O. y! Y- k
<> </P> ! X( L- d @" n3 T. C, |* `<>Set recordset = object.OpenRecordset (type, options, lockedits) </P>$ E( M6 n: i0 N; m3 A" N7 k
<> </P> 9 O1 U* l, g/ Y; w<>The OpenRecordset method syntax has these parts. </P> 4 ^8 h! K. Z# i; b! c) ]<> </P> ! J- m; j- K @' G0 p. N<>art Description </P>) D: W+ ?% C. Y9 t: y1 R* V9 K2 t) ?
<>recordset An object variable that represents the Recordset object you wantt to </P>1 l. ]$ f0 H; @
<>open. </P> ) @" @# o% }! e0 c# Y( K<>object An object variable that represents an existing object from which you </P> 1 W& u4 s0 b5 Y5 i0 s0 I<>want to create the new Recordset. </P>: v' s6 U' K% x+ ?- t3 B
<>source A String specifying the source of the records for the new Recordset. </P> 2 u9 t5 @: E& b+ J! _- i6 @<>The source can be a table name, a query name, or an SQL statement that </P> 2 m) n1 D0 i7 p+ Q& ~7 g<>returns records. For table-type Recordset objects in Microsoft Jet databases, </P># X0 e' @' j; ?: Y. S: J6 j0 t* M2 t
<>the source can only be a table name. </P>5 X) d. B! I" `3 k2 r
<>type Optional. A constant that indicates the type of Recordset to open, as </P>* u+ p8 }4 R2 d; ~9 e5 v0 G. {
<>specified in Settings. </P> . F& ^ }. C- t<>options Optional. A combination of constants that specify characteristics of </P>/ {: }) e& L+ c. J ?5 V- i
<>the new Recordset, as listed in Settings. </P>) `0 i, o3 M; N" N _
<>lockedits Optional. A constant that determines the locking for the Recordsset, </P> j( h' V. [" _<P>as specified in Settings. </P>3 [" g! Q5 T$ [7 _* b. X1 [
<P>Settings </P>! q4 T2 y2 q9 [) R8 ]
<P> </P> 4 y" z1 c9 O; g$ G( b<P>You can use one of the following constants for the type argument. </P> ) F. R+ J7 m1 z1 V* I3 C<P> </P> * V7 S' F# [/ D' G- C<P>Constant Description </P>! S! a1 @' N0 B- e' Y' Y4 ?
<P> </P> ' ?* }% p! v: K+ Y5 k- m% e/ f<P> </P> % [) k! S2 a+ \) Z<P>dbOpenTable Opens a table-type Recordset object (Microsoft Jet workspaces </P> 5 \6 W5 t" r4 l. v- j& J<P>only). </P>5 N R* h" ?+ i9 K! i @' S
<P>dbOpenDynamic Opens a dynamic-type Recordset object, which is similar to an </P>3 \: f6 c) b3 P+ G6 \* ^3 T" W
<P>ODBC dynamic cursor. (ODBCDirect workspaces only) </P>8 \% T4 T" t5 k
<P>dbOpenDynaset Opens a dynaset-type Recordset object, which is similar to an </P>5 @, u- C, `: V+ T) s' `" a" I# O
<P>ODBC keyset cursor. </P>& T4 P) g$ x" |: X* T/ @5 h
<P>dbOpenSnapshot Opens a snapshot-type Recordset object, which is similar to an </P>0 H3 Q7 t$ f, I) c9 d
<P>ODBC static cursor. </P> 2 g3 l5 Y' P" v<P>dbOpenForwardOnly?Opens a forward-only-type Recordset object. </P> # @* p- T3 | i9 x/ J<P>Note If you open a Recordset in a Microsoft Jet workspace and you don't </P> ; G' ]0 m3 a: O* e4 {<P>specify a type, OpenRecordset creates a table-type Recordset, if possible. If </P>% G z) v7 V$ i) u* X4 U5 o; C2 X
<P>you specify a linked table or query, OpenRecordset creates a dynaset-type </P> X ^! L8 L* J5 _1 P
<P>Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnl </P> 2 S* r Y( u" I0 w8 `0 G<P>y. </P> " ]' D! z0 T1 g7 j7 A8 \( B<P> </P> $ G( ?+ B2 g! `) V0 J% v<P>You can use a combination of the following constants for the options </P> * T+ y6 q) X! s) R# {" P<P>argument. </P>' H6 V7 \* d; {$ Z$ K
<P> </P>7 K/ r$ e& M, ^1 H+ H
<P>Constant Description </P> + _+ t2 w \) Q# ~6 O<P>dbAppendOnly?Allows users to append new records to the Recordset, but </P> k7 F- e2 l( i( b7 W9 ?' r
<P>prevents them from editing or deleting existing records (Microsoft Jet </P> , m( M7 n7 o7 Z& R<P>dynaset-type Recordset only). </P>5 E3 ?+ t* H# g
<P>dbSQLPassThrough?Passes an SQL statement to a Microsoft Jet-connected ODBC </P>% v$ E" O0 C* G
<P>data source for processing (Microsoft Jet snapshot-type Recordset only). </P>4 J/ d0 E4 Q3 \3 Z
<P>dbSeeChanges Generates a run-time error if one user is changing data that </P> + f2 W3 Z# e+ {2 j" @( [ R2 _<P>another user is editing (Microsoft Jet dynaset-type Recordset only). This is </P> 3 ^0 b, R7 E3 Y! J<P>useful in applications where multiple users have simultaneous read/write </P>8 j! G; K: i! u( U" K- S! ?
<P>access to the same data. </P>* R, ^8 d& F* B- l; t. O4 B1 Q; ?% ~
<P>dbDenyWrite?Prevents other users from modifying or adding records (Microsoft </P> 1 D1 M8 U4 t4 u4 B<P>Jet Recordset objects only). </P>+ D, ^* T B; D8 |: K9 ]
<P>dbDenyRead?Prevents other users from reading data in a table (Microsoft Jet </P> 6 S! e% Q! W7 w! K4 f; o<P>table-type Recordset only). </P> 0 O0 D2 F- `& t( w) i6 h7 ?<P>dbForwardOnly?Creates a forward-only Recordset (Microsoft Jet snapshot-type </P> : M0 e! \' q/ j1 T- }& w9 ]' a<P>Recordset only). It is provided only for backward compatibility, and you </P>: ~ N) c5 s$ S# Q9 y. U/ W- _
<P>should use the dbOpenForwardOnly constant in the type argument instead of </P> y! \/ t5 y* U
<P>using this option. </P> 1 K# e3 U+ N6 j<P>dbReadOnly?Prevents users from making changes to the Recordset (Microsoft Jet </P> " k9 k% T9 e2 W' k( B" b% Y/ v<P>only). The dbReadOnly constant in the lockedits argument replaces this </P>8 J& X. f {. j! Q
<P>option, which is provided only for backward compatibility. </P> : ]7 J$ S$ v8 c8 D8 d/ B6 d<P>dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only). </P>8 c* G2 P- e1 m) o3 c
<P>dbExecDirect?Runs a query by skipping SQLPrepare and directly calling </P>& I7 T( `! o& p, `1 Z
<P>SQLExecDirect (ODBCDirect workspaces only). Use this option only when you抮e </P> / n3 b" o' l( j9 L. z D<P>not opening a Recordset based on a parameter query. For more information, see </P> 6 p9 G' ^6 t1 Y( e- Y; C2 D1 R! V<P>the "Microsoft ODBC 3.0 Programmer抯 Reference." </P>1 t! w; t& a! M- o
<P>dbInconsistent?Allows inconsistent updates (Microsoft Jet dynaset-type and </P> 8 w n" I1 w/ H; t<P>snapshot-type Recordset objects only). </P>' E! |2 C/ F3 o1 T Y- Y- G
<P>dbConsistent?Allows only consistent updates (Microsoft Jet dynaset-type and </P> 4 j( x' J2 W2 a9 U) X) T0 Z<P>snapshot-type Recordset objects only). </P> 9 d4 J$ c5 h! A3 D: X3 R<P>Note The constants dbConsistent and dbInconsistent are mutually exclusive, </P>( d0 W. K, @; o/ ~0 u
<P>and using both causes an error. Supplying a lockedits argument when options </P>4 v7 D6 e7 \5 o# w$ E$ u
<P>uses the dbReadOnly constant also causes an error. </P> " d2 I+ `- n% h8 K/ \9 P; ^8 d<P> </P>7 O- l1 ^( k( ]6 R) ^0 t G- X' ~
<P>You can use the following constants for the lockedits argument. </P>! E. t9 D6 t; i5 m. D# O
<P> </P> + S' x) J6 F- ~2 g4 Z! l1 }<P>Constant Description </P> ! G, T4 G! P- H a- o<P>dbReadOnly Prevents users from making changes to the Recordset (default for </P> 1 b3 g( J) t2 ]- S2 F3 K<P>ODBCDirect workspaces). You can use dbReadOnly in either the options argument </P>: [# K3 H% l: ^3 u, X% b
<P>or the lockedits argument, but not both. If you use it for both arguments, a </P> - x. {3 H, L8 a2 T; R2 h<P>run-time error occurs. </P>) r1 I$ ^9 }) p" t8 W' n
<P>dbPessimistic?Uses pessimistic locking to determine how changes are made to </P>0 p X+ o% y! q% Z) b. ~+ B4 E
<P>the Recordset in a multiuser environment. The page containing the record </P>& v3 X0 K [" H+ B* r
<P>you're editing is locked as soon as you use the Edit method (default for </P> % K& v( X; z/ j) ]<P>Microsoft Jet workspaces). </P> 3 n8 \3 G9 g. v* J<P>dbOptimistic?Uses optimistic locking to determine how changes are made to the </P> C& R" e: _; b, N# \<P>Recordset in a multiuser environment. The page containing the record is not </P>% T+ A% `+ l' @, }
<P>locked until the Update method is executed. </P> - [4 X5 r2 A D& q. k' k<P>dbOptimisticValue?Uses optimistic concurrency based on row values (ODBCDirect </P> |% ~6 C" i( F% X7 `
<P>workspaces only). </P> + w3 S( W; T1 y6 X<P>dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect workspaces </P>/ |$ Z2 y: k- W6 _
<P>only). </P>9 Y) S) Q" j! p6 K6 z- C1 H3 g
<P>Remarks </P>" F$ t" {- W: V' Q1 Q3 q, h
<P> </P>2 R3 Z3 a( D, K0 r
<P>In a Microsoft Jet workspace, if object refers to a QueryDef object, or a </P> 3 @( a# g I$ Y* g% L+ U<P>dynaset- or snapshot-type Recordset, or if source refers to an SQL statement </P>, ~9 x& A# j+ Z7 f2 o0 [" V: c
<P>or a TableDef that represents a linked table, you can't use dbOpenTable for </P>3 o0 z% p* j! T
<P>the type argument; if you do, a run-time error occurs. If you want to use an </P> 1 M, m8 T* ^% u, z! T* F# b; Z! {<P>SQL pass-through query on a linked table in a Microsoft Jet-connected ODBC </P>) u. a% K9 r5 o) X) Z2 T' f$ |. A
<P>data source, you must first set the Connect property of the linked table's </P>% V6 p. r P2 t3 _- T$ L( l
<P>database to a valid ODBC connection string. If you only need to make a single </P> [0 p& y* @4 P<P>pass through a Recordset opened from a Microsoft Jet-connected ODBC data </P>! u2 O% }1 L( [1 Q9 s. z. G
<P>source, you can improve performance by using dbOpenForwardOnly for the type </P>8 ?4 }) G/ L; X P% f4 [, n% _
<P>argument. </P>& S8 n7 n8 i5 ?# r _# ~- h
<P> </P>9 K9 v8 K2 S6 r8 H w
<P>If object refers to a dynaset- or snapshot-type Recordset, the new Recordset </P>9 B; K6 [( ?5 n: h
<P>is of the same type object. If object </P>/ e2 J; B/ T7 G
<P> refers to a table-type Recordset object, the type of the new object is a </P> : ^- G) Z- g! }( J6 `: F* i& ^8 b2 p; A<P>dynaset-type Recordset. You can't open new Recordset objects from forward-only </P>4 T( R6 A% l( ]4 }* @# o
<P>杢ype or ODBCDirect Recordset objects. </P>: E' _ @5 H& I7 C- a5 @ ^
<P>In an ODBCDirect workspace, you can open a Recordset containing more than one </P>6 U$ b' J% J+ R
<P>select query in the source argument, such as </P> ( j/ F- R6 } [6 u- Z) P w* c; f<P> </P> " @7 g3 Q* X2 K' C<P>"SELECT LastName, FirstName FROM Authors </P> ) a P& J9 O4 _ E5 x<P>WHERE LastName = 'Smith'; </P>; V% I$ Z& X2 Y
<P>SELECT Title, ISBN FROM Titles </P> 5 a, \* }) ?) i/ T2 ?<P>WHERE ISBN Like '1-55615-*'" </P> 2 v: b7 p9 X# s<P> </P>5 |* \8 \2 c) ^9 u4 Q3 K
<P>The returned Recordset will open with the results of the first query. To </P> 0 a# ?" M+ F- G/ U<P>obtain the result sets of records from subsequent queries, use the </P>9 n* s. y3 d4 R x7 R5 t6 O9 u
<P>NextRecordset method. </P> , R6 f" ~$ E% p<P> </P> * U$ [5 O: c* U( F2 R- W<P>Note You can send DAO queries to a variety of different database servers </P>5 t5 _; k- L, \8 d1 m" Y# E
<P>with ODBCDirect, and different servers will recognize slightly different </P>& k4 `6 S/ F4 D5 R1 n N0 W
<P>dialects of SQL. Therefore, context-sensitive Help is no longer provided for </P>4 u# O" ~# l" q1 R
<P>Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still </P> : X. H& S; A, p5 Q- B9 f1 o8 b3 B" Q<P>included through the Help menu. Be sure to check the appropriate reference </P> + f/ i+ ?9 n( J; R0 F' O<P>documentation for the SQL dialect of your database server when using either </P>+ w3 M9 F4 T$ I4 i, x8 P
<P>ODBCDirect connections or pass-through queries in Microsoft Jet-connected </P> 0 R; y( \4 r$ o; i: S<P>client/server applications. </P>5 s4 H/ v/ C% ]/ w4 e
<P> </P> 2 Z8 `# X# a' v5 Q6 q<P>Use the dbSeeChanges constant in a Microsoft Jet workspace if you want to </P>" P& [6 r" k4 x) ~& k* i
<P>trap changes while two or more users are editing or deleting the same record. </P> 3 x# ^3 [" Z2 G<P>For example, if two users start editing the same record, the first user to </P> 3 n$ D1 x" Y9 M$ k6 _2 q6 r# Y<P>execute the Update method succeeds. When the second user invokes the Update </P>- }6 E9 f5 I3 S4 ^! H# z3 e, ^7 \
<P>method, a run-time error occurs. Similarly, if the second user tries to use </P>: v3 a1 a* G. L
<P>the Delete method to delete the record, and the first user has already </P> W u9 D) A9 Z" \, O! z
<P>changed it, a run-time error occurs. </P>/ x. j y( \% C6 i
<P> </P>1 k E- @8 x& @
<P>Typically, if the user gets this error while updating a record, your code </P>% h0 C5 s; L1 A( M9 ~2 d) C
<P>should refresh the contents of the fields and retrieve the newly modified </P>/ j" I: ?& C. E- {) U
<P>values. If the error occurs while deleting a record, your code could display </P>2 N6 S4 K/ i" q& J: u
<P>the new record data to the user and a message indicating that the data has </P> " f% t; {2 g2 B6 b6 ?<P>recently changed. At this point, your code can request a confirmation that </P>9 m1 V7 E' s2 A7 l: C* I# x% N
<P>the user still wants to delete the record. </P> 3 O8 S- l9 _7 W! S<P> </P> % J$ ^' K9 R! e5 r0 J, e<P>You should also use the dbSeeChanges constant if you open a Recordset in a </P> 1 l4 Q5 Y4 y( r- F, \<P>Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server 6.0 (or </P> ) \9 J2 ]' C1 p! I4 T/ o% x<P>later) table that has an IDENTITY column, otherwise an error may result. </P># V) r) X" Q& @) B1 l8 m, p$ j- q
<P> </P>. M+ C/ y) F& H, H) `# Z" |. L. I
<P>In an ODBCDirect workspace, you can execute asynchronous queries by setting </P>0 P1 p$ Q, Y8 H% \
<P>the dbRunAsync constant in the options argument. This allows your application </P>. a" u7 u7 T) x0 g3 i
<P>to continue processing other statements while the query runs in the </P>5 Y l' K% l3 v& n( G) x2 @
<P>background. But, you cannot access the Recordset data until the query has </P>$ T9 e7 P8 c# t; u5 l' U3 C
<P>completed. To determine whether the query has finished executing, check the </P> @! \) X) A' t* I9 |7 d% c1 ]<P>StillExecuting property of the new Recordset. If the query takes longer to </P> 9 k; {- s! l7 X5 h' P! x<P>complete than you anticipated, you can terminate execution of the query with </P> 6 o- l) G, i/ E( g/ P" E9 i<P>the Cancel method. </P>6 ~* s* r6 u3 A- R
<P> </P> * a, L% k) b+ }. }7 [<P>Opening more than one Recordset on an ODBC data source may fail because the </P>/ J1 e: `4 q" @. a$ ?2 z
<P>connection is busy with a prior </P> / C5 ]7 \* u' K<P>OpenRecordset call. One way around this is to use a server-side cursor and </P> D" @0 ]0 f7 b6 U
<P>ODBCDirect, if the server supports this. Another solution is to fully </P>0 x& q I! y3 [$ _/ Y# D
<P>populate the Recordset by using the MoveLast method as soon as the Recordset </P>3 E' [* b. g9 O; t
<P>is opened. </P> ) b7 i4 c9 }9 s* y. H+ Y% z4 j9 Z" H<P> </P> - f) u- u1 n9 w2 R- A% `1 f+ @6 f<P>If you open a Connection object with DefaultCursorDriver set to </P>' r& M5 p& R; W: o
<P>dbUseClientBatchCursor, you can open a Recordset to cache changes to the data </P>9 s: ] `6 U' J0 T; D7 x5 |" f
<P>(known as batch updating) in an ODBCDirect workspace. Include dbOptimisticBatc </P> ' k) a- l6 e5 n4 T7 O( `<P>h in the lockedits argument to enable update caching. See the Update method </P>3 S. K$ U, E6 h# s0 Y, u% \0 J
<P>topic for details about how to write changes to disk immediately, or to cache </P># _( y& a7 m" s. a) `, T: j
<P>changes and write them to disk as a batch. </P> 0 _) c/ R9 B7 f+ N<P> </P>! ?0 U6 h, f# U1 Y X5 E
<P>Closing a Recordset with the Close method automatically deletes it from the </P> 0 d; Z4 a. ` _; U W1 w0 Y 9 c, \" C( n# O8 r7 A2 p<P>Recordsets collection. </P>& F, L) Q2 i. E; o$ J" V/ E
<P> </P> % r' v# _2 P2 z3 m6 V5 D& K<P>Note If source refers to an SQL statement composed of a string concatenated </P> ( Q( h* O! R0 G" O& Q<P>with a non-integer value, and the system parameters specify a non-U.S. </P>. A3 V! z/ ?$ d B, t" q
<P>decimal character such as a comma (for example, strSQL = "PRICE > " & </P>. L5 r! u5 q3 u# v" |3 y
<P>lngPrice, and lngPrice = 125,50), an error occurs when you try to open the </P>/ l, r3 O$ V8 g g4 o
<P>Recordset. This is because during concatenation, the number will be converted </P> y8 t# r4 _7 h" @) q ]" f' R- X<P>to a string using your system's default decimal character, and SQL only </P> & b' y( K o% U5 k! {$ t9 J<P>accepts U.S. decimal characters.</P>