<> </P> 8 p+ k; a( m; b% Q" I4 ~! S<>Creates a new Recordset object and appends it to the Recordsets collection. </P>7 E; r* S& }6 z% h
<> </P>8 `6 i" w' \) B% r4 r
<>Syntax </P>; H% a9 A3 W2 |" C! ?. y* L
<> </P>. e2 f$ N4 S% y4 r( H
<>For Connection and Database objects: </P> , [- t! r. e( g( @* k3 b<> </P> & U- C3 `4 N; B7 ~6 ?! }; ]' G<>Set recordset = object.OpenRecordset (source, type, options, lockedits) </P> * A4 d2 _% S# j1 Y$ {<> </P> 9 b. m2 F9 U7 q" Y) I0 p8 |<>For QueryDef, Recordset, and TableDef objects: </P>& U% i4 j! P: d L2 {$ T
<> </P> . ~6 w: x H. E+ M* x, X<>Set recordset = object.OpenRecordset (type, options, lockedits) </P>" g! v1 a( e) q) z* [2 {1 J% O9 \# I. w
<> </P>0 x7 m4 j" E3 Y
<>The OpenRecordset method syntax has these parts. </P>, u/ L; d4 f$ n% Y. h x
<> </P> 4 h$ S; N3 X% d) Y, q+ S# c0 j# k5 X<>art Description </P> . h$ O6 y, v$ f2 K5 ~ u% m# F( n5 b<>recordset An object variable that represents the Recordset object you wantt to </P> # C0 R; X4 ]2 x! c; n: ]5 _<>open. </P>* C* H2 u- h3 J/ p$ {) X* k
<>object An object variable that represents an existing object from which you </P>3 p w* O% z) F4 @* w- y* Y
<>want to create the new Recordset. </P> . e1 G9 T* ^1 ^4 g- p: a1 Y2 C<>source A String specifying the source of the records for the new Recordset. </P>) v/ B, ?: ?! h9 o; o; X" N
<>The source can be a table name, a query name, or an SQL statement that </P> ; N8 r" u( S: R( j% M<>returns records. For table-type Recordset objects in Microsoft Jet databases, </P>2 E& z. t/ |1 }' A3 r- v i% R
<>the source can only be a table name. </P>) d L/ ?8 J b& t, t' V6 d
<>type Optional. A constant that indicates the type of Recordset to open, as </P>$ U" p/ V' l5 Y5 }( h* G
<>specified in Settings. </P> 7 J5 v' z+ W( e- ~6 ?8 s, o- G<>options Optional. A combination of constants that specify characteristics of </P> ( q6 C3 K: q% D; V0 f<>the new Recordset, as listed in Settings. </P> 1 H; Z9 r0 G" v6 o: j0 y& n<>lockedits Optional. A constant that determines the locking for the Recordsset, </P> 6 @0 r% {1 F5 z1 B5 t<P>as specified in Settings. </P>6 k3 J* e- _6 u8 j T4 ^' j
<P>Settings </P> * @# J- R1 _8 M T' B& g<P> </P> : s. R6 r- J+ J7 ~; p; k) `( {<P>You can use one of the following constants for the type argument. </P> # I- T+ y' c3 a1 ^. b<P> </P>6 E( v! Q( U" [4 s$ R$ N: Q) F ?
<P>Constant Description </P> ; N& D1 i; D$ x4 |+ c1 {<P> </P> ) `% a5 e. t) j<P> </P>' g' A9 `$ z! g. h' W$ q+ q- ?
<P>dbOpenTable Opens a table-type Recordset object (Microsoft Jet workspaces </P>5 C" D# O: N4 N# U5 j' W7 u
<P>only). </P>! {0 H7 H1 e4 h, t. g2 {5 x
<P>dbOpenDynamic Opens a dynamic-type Recordset object, which is similar to an </P> " U- C' E7 G6 F2 j, Q<P>ODBC dynamic cursor. (ODBCDirect workspaces only) </P># i' |7 z/ c) M$ f; W: N5 b( h& U
<P>dbOpenDynaset Opens a dynaset-type Recordset object, which is similar to an </P>+ x5 a' W2 y% P1 n+ `" M5 c0 p* z X
<P>ODBC keyset cursor. </P> : \& i K/ Z/ |/ e. B6 j' i<P>dbOpenSnapshot Opens a snapshot-type Recordset object, which is similar to an </P> 5 Q9 B" o, F# I' D<P>ODBC static cursor. </P> ! L) I; @7 G5 C$ N: o& r* r2 ^<P>dbOpenForwardOnly?Opens a forward-only-type Recordset object. </P> 0 l3 u' o: o0 B- ]) Q. e% x$ e<P>Note If you open a Recordset in a Microsoft Jet workspace and you don't </P> & H g" s3 K0 u1 e' i. ]3 m<P>specify a type, OpenRecordset creates a table-type Recordset, if possible. If </P>* C. a% d( p7 q
<P>you specify a linked table or query, OpenRecordset creates a dynaset-type </P> ; z3 ]& ]' H1 H+ q- B<P>Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnl </P> ; X9 [: v: p$ M6 R+ U<P>y. </P> : D) N. F e, K<P> </P>. D, N$ I2 H* c9 u8 H. [% s
<P>You can use a combination of the following constants for the options </P>2 R2 A& J( g0 m* A, P
<P>argument. </P>3 s/ c- k6 P+ a! i0 X# Z
<P> </P>8 ~0 V( N$ z7 E6 f
<P>Constant Description </P>5 Z) O' n$ r0 L: U6 ?3 V4 J r; Z$ y
<P>dbAppendOnly?Allows users to append new records to the Recordset, but </P>) F3 T0 ?3 {1 ]( C8 C
<P>prevents them from editing or deleting existing records (Microsoft Jet </P> n& T1 d/ Y0 ]6 L3 U, k% N; ~<P>dynaset-type Recordset only). </P>5 A* n: H6 N# M. n
<P>dbSQLPassThrough?Passes an SQL statement to a Microsoft Jet-connected ODBC </P>9 v+ G9 b2 d3 l/ y1 y( N8 D* @
<P>data source for processing (Microsoft Jet snapshot-type Recordset only). </P>7 }' f! V7 [" m. W
<P>dbSeeChanges Generates a run-time error if one user is changing data that </P># H$ h9 u' R. I0 i: T
<P>another user is editing (Microsoft Jet dynaset-type Recordset only). This is </P> 5 ^" ~) A( p$ L<P>useful in applications where multiple users have simultaneous read/write </P> + J m" K# }9 }7 y3 I: z: M E<P>access to the same data. </P>$ x$ s$ R3 m$ a3 [! ~1 t
<P>dbDenyWrite?Prevents other users from modifying or adding records (Microsoft </P>" R' V! e1 K( Q# N
<P>Jet Recordset objects only). </P>0 z3 ]3 Q) z& ~" \& @8 V
<P>dbDenyRead?Prevents other users from reading data in a table (Microsoft Jet </P>4 B8 w. [% z; h( q: e7 L
<P>table-type Recordset only). </P> " P/ o6 G. ~7 O/ P' l<P>dbForwardOnly?Creates a forward-only Recordset (Microsoft Jet snapshot-type </P>! x: Y2 R7 \' f9 a
<P>Recordset only). It is provided only for backward compatibility, and you </P> / U+ C$ T" \5 Z1 G. i9 U- ~* w: W% H<P>should use the dbOpenForwardOnly constant in the type argument instead of </P>+ g+ G. P ]( @# w# ^% R+ k( H
<P>using this option. </P> 8 j8 g4 @$ q n# H# `<P>dbReadOnly?Prevents users from making changes to the Recordset (Microsoft Jet </P>! y/ B' H! C, D, f) \
<P>only). The dbReadOnly constant in the lockedits argument replaces this </P> / z7 s: M% Y9 k* g0 n+ U<P>option, which is provided only for backward compatibility. </P>. n2 D; _3 a% @5 Q! o4 Q
<P>dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only). </P> ; A7 Y: N: ^% g( X<P>dbExecDirect?Runs a query by skipping SQLPrepare and directly calling </P> / v/ T3 a5 h6 ^& n; z" `9 Q<P>SQLExecDirect (ODBCDirect workspaces only). Use this option only when you抮e </P>/ o4 z- Z0 Y) Z, J) T
<P>not opening a Recordset based on a parameter query. For more information, see </P> 6 H6 l4 L. Y) Q' m<P>the "Microsoft ODBC 3.0 Programmer抯 Reference." </P> # M& S( n8 K. S+ L! p- R5 K<P>dbInconsistent?Allows inconsistent updates (Microsoft Jet dynaset-type and </P> 1 G j& x0 v9 J, L<P>snapshot-type Recordset objects only). </P> ( r& i) |$ W6 Z4 l<P>dbConsistent?Allows only consistent updates (Microsoft Jet dynaset-type and </P>7 @3 G3 A7 P# Z) o q
<P>snapshot-type Recordset objects only). </P>/ g4 G3 G: E3 K2 k( |' t+ O
<P>Note The constants dbConsistent and dbInconsistent are mutually exclusive, </P>2 r! G3 p$ L2 u% K, F0 p
<P>and using both causes an error. Supplying a lockedits argument when options </P> , O6 T9 A1 P7 Q, w$ F<P>uses the dbReadOnly constant also causes an error. </P> 4 b" E* k% @% O) S( [3 c3 K<P> </P> ) Q) Y7 M' Z4 v' ~, w<P>You can use the following constants for the lockedits argument. </P> $ ^5 Q8 Z* Q4 Y4 Q, z' F<P> </P> 8 L$ x; B6 |2 D" Q<P>Constant Description </P> : l, E# `5 [+ Z+ ^# I<P>dbReadOnly Prevents users from making changes to the Recordset (default for </P> ; n1 @" |9 U9 D! y<P>ODBCDirect workspaces). You can use dbReadOnly in either the options argument </P> * |; g& M4 U+ c) j<P>or the lockedits argument, but not both. If you use it for both arguments, a </P>: h- c& d; R. L0 |- z' e. @* d, f
<P>run-time error occurs. </P>% S. x$ y5 Z" Z
<P>dbPessimistic?Uses pessimistic locking to determine how changes are made to </P>- Q* w5 a& X+ l, N
<P>the Recordset in a multiuser environment. The page containing the record </P># S' B5 b; b0 p7 w/ }
<P>you're editing is locked as soon as you use the Edit method (default for </P> 7 e) b+ q6 x$ V+ j! O) {2 ^( W: M" ^<P>Microsoft Jet workspaces). </P>) M; r" M4 F' g/ k4 W: }
<P>dbOptimistic?Uses optimistic locking to determine how changes are made to the </P> & A1 y- y2 j! k, J3 `<P>Recordset in a multiuser environment. The page containing the record is not </P> ) z" q% N9 A/ E$ k, M$ x<P>locked until the Update method is executed. </P> 8 j$ `0 k s; D# J m<P>dbOptimisticValue?Uses optimistic concurrency based on row values (ODBCDirect </P>) j ?! {* D8 N; _
<P>workspaces only). </P>* \# {: }- O! [6 Q0 D5 m% F
<P>dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect workspaces </P>6 d( M O1 Z4 t3 ^! ~8 E
<P>only). </P>* M8 B, X$ r3 N
<P>Remarks </P>/ ~6 j/ ?; ?. q- l" O3 C/ y5 N) L, I
<P> </P> & S* U! ^* e- M$ n, x' K% b& l<P>In a Microsoft Jet workspace, if object refers to a QueryDef object, or a </P> . w/ S7 q. f; E) U. p<P>dynaset- or snapshot-type Recordset, or if source refers to an SQL statement </P> 2 H. I+ @% k8 @( S' E1 C& G( D<P>or a TableDef that represents a linked table, you can't use dbOpenTable for </P> , M' Q# R/ v& n9 W1 q, f' Y% Z<P>the type argument; if you do, a run-time error occurs. If you want to use an </P> 8 q+ d$ `$ ?! n<P>SQL pass-through query on a linked table in a Microsoft Jet-connected ODBC </P>! _+ t' _1 G8 ^; u
<P>data source, you must first set the Connect property of the linked table's </P> ( R& ^2 z$ q" G' X4 Z0 ]<P>database to a valid ODBC connection string. If you only need to make a single </P> , M3 l8 t! L0 {<P>pass through a Recordset opened from a Microsoft Jet-connected ODBC data </P>1 s8 g) s$ B5 Q8 r- i! P# F) W
<P>source, you can improve performance by using dbOpenForwardOnly for the type </P> : j# ]! {8 g! x( z<P>argument. </P> ! m4 n/ K6 U! Q; E( v* f4 R<P> </P>9 S& t- O9 p$ R- N' F- Z6 M, r9 S
<P>If object refers to a dynaset- or snapshot-type Recordset, the new Recordset </P> 0 U, b$ g/ W1 A" Q: v! |0 J<P>is of the same type object. If object </P> ( y1 i4 H. ~3 O9 P% F<P> refers to a table-type Recordset object, the type of the new object is a </P># ^4 s' k; R/ \' D( u* u8 V3 A
<P>dynaset-type Recordset. You can't open new Recordset objects from forward-only </P> / _: B+ W$ i" D7 `<P>杢ype or ODBCDirect Recordset objects. </P> G9 n/ t' {2 B! c6 V
<P>In an ODBCDirect workspace, you can open a Recordset containing more than one </P>) }3 n" i' q7 N3 `. ^" J: P
<P>select query in the source argument, such as </P> ^/ a$ V2 c; J7 C* w
<P> </P> 0 Y/ k( N( ^' {# H5 c, V p! z: ~/ f<P>"SELECT LastName, FirstName FROM Authors </P>& y a/ Q6 n9 ^; T
<P>WHERE LastName = 'Smith'; </P>: L! q. z/ @2 D, `6 r" @3 D! H) F
<P>SELECT Title, ISBN FROM Titles </P>2 }7 x# ` g! B! A& t1 L
<P>WHERE ISBN Like '1-55615-*'" </P> $ G6 I6 ?- v5 D" g<P> </P>' w! k" A% s5 d1 \7 ^9 S
<P>The returned Recordset will open with the results of the first query. To </P> $ v" y) O5 T$ A! s) |<P>obtain the result sets of records from subsequent queries, use the </P> ) j+ j& {. c; F0 E1 L1 x<P>NextRecordset method. </P> 9 q& {, F' d! {- _4 [( x<P> </P>( p# _" U+ }$ ^4 G/ T
<P>Note You can send DAO queries to a variety of different database servers </P> 4 ?. A: \7 `% S$ V<P>with ODBCDirect, and different servers will recognize slightly different </P>) q4 {1 S# U |# J8 C8 e; w3 h
<P>dialects of SQL. Therefore, context-sensitive Help is no longer provided for </P> 2 g. s: n% M+ i, }" [8 F P; j' Q( a<P>Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still </P>. W' s _3 @0 o2 P, [6 y
<P>included through the Help menu. Be sure to check the appropriate reference </P>' m3 y3 f5 y5 N, s! d3 |3 i: S
<P>documentation for the SQL dialect of your database server when using either </P> p ~$ F% W6 o6 a7 Z<P>ODBCDirect connections or pass-through queries in Microsoft Jet-connected </P>+ C$ p1 m# k6 p# w2 t
<P>client/server applications. </P> & @( N$ V" s1 X# o3 w2 G7 i! r( ^& z O<P> </P>; c( }' W$ i$ ~7 o" u5 D' L
<P>Use the dbSeeChanges constant in a Microsoft Jet workspace if you want to </P> , X& v# S) K" k6 L b<P>trap changes while two or more users are editing or deleting the same record. </P> 7 N0 N: p+ u' ~% Q/ q# y7 C6 a' A3 }<P>For example, if two users start editing the same record, the first user to </P> 3 o3 K; Z- r1 L0 [% M- |, U5 {<P>execute the Update method succeeds. When the second user invokes the Update </P>" J, M0 J/ S+ d9 i5 B
<P>method, a run-time error occurs. Similarly, if the second user tries to use </P> : |! i; U: j g6 z6 {/ c) L<P>the Delete method to delete the record, and the first user has already </P>- }$ |- K0 Z: I
<P>changed it, a run-time error occurs. </P>' d& o% ^4 j9 W
<P> </P>8 p9 H- T! D1 x5 n$ ^! M: p% g, w
<P>Typically, if the user gets this error while updating a record, your code </P>4 u6 _% y3 n0 l# {
<P>should refresh the contents of the fields and retrieve the newly modified </P> 7 \4 R5 I- K: C5 i2 w! ]<P>values. If the error occurs while deleting a record, your code could display </P>* r& a; m. \4 g- ?: w: \
<P>the new record data to the user and a message indicating that the data has </P> 1 g- y6 o6 ?' e6 u<P>recently changed. At this point, your code can request a confirmation that </P>: m8 |, i2 l! f. a4 e( E; B
<P>the user still wants to delete the record. </P> 1 E. p1 F) J& ?4 c, j3 y$ v<P> </P>" ~" {: \% p0 Z( \! K* J4 [6 ~% t% f
<P>You should also use the dbSeeChanges constant if you open a Recordset in a </P> ) R' |6 |4 j) A' ]5 s# M<P>Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server 6.0 (or </P>; q t! M8 m9 X
<P>later) table that has an IDENTITY column, otherwise an error may result. </P>( m" X/ e8 Z% S+ n0 W
<P> </P> * T' a2 ^0 Z: c# q<P>In an ODBCDirect workspace, you can execute asynchronous queries by setting </P>5 \1 F5 b3 l! F( i
<P>the dbRunAsync constant in the options argument. This allows your application </P> a3 f& M* l9 Z<P>to continue processing other statements while the query runs in the </P>/ f3 Z* d0 _9 w! R4 u' `0 g
<P>background. But, you cannot access the Recordset data until the query has </P>5 l% B4 a. ?" b3 `4 F2 s% T
<P>completed. To determine whether the query has finished executing, check the </P>1 Z2 U4 b" p& D* k9 Y: b/ ^# v/ }
<P>StillExecuting property of the new Recordset. If the query takes longer to </P> 5 L- k! I/ m: ?. S# b: f9 F<P>complete than you anticipated, you can terminate execution of the query with </P>9 O1 v* F |$ S# a6 Y4 W6 ~# B
<P>the Cancel method. </P> 9 P; N& f8 e) J" I/ T2 Q; \<P> </P> 6 A9 A* r1 G* a6 U3 U2 Z<P>Opening more than one Recordset on an ODBC data source may fail because the </P>; h9 t0 G9 X L2 a
<P>connection is busy with a prior </P>+ i6 T2 [( g8 I
<P>OpenRecordset call. One way around this is to use a server-side cursor and </P> 0 O0 V2 s! I% B% m- S0 E<P>ODBCDirect, if the server supports this. Another solution is to fully </P> 4 r2 Z7 e! t8 P4 N4 g<P>populate the Recordset by using the MoveLast method as soon as the Recordset </P> : }! S7 y' X7 n, ~! A# c<P>is opened. </P>" A4 ~9 ~- N" {% W
<P> </P> 0 i$ ]$ a- t& }8 D& k$ @6 a$ c<P>If you open a Connection object with DefaultCursorDriver set to </P> " L# Q6 w- H) V* z7 l9 @3 h<P>dbUseClientBatchCursor, you can open a Recordset to cache changes to the data </P> 9 F) S- [! Z" d. e6 M2 S, K<P>(known as batch updating) in an ODBCDirect workspace. Include dbOptimisticBatc </P>3 b/ b6 Z4 E; G. X
<P>h in the lockedits argument to enable update caching. See the Update method </P>+ e/ h" h" i- y& J, [
<P>topic for details about how to write changes to disk immediately, or to cache </P> $ O5 f" u; [' G) E* t( q<P>changes and write them to disk as a batch. </P> , W h# ]# c0 ]# i, }- v' ^7 {<P> </P>+ A" X* G/ Z0 ^. x6 i
<P>Closing a Recordset with the Close method automatically deletes it from the </P> - D1 ]: B" ?% X$ o9 U6 c2 C" V* B/ Z/ U* | D0 R+ v
<P>Recordsets collection. </P> : x7 @8 a6 Q1 H4 A9 k% t( b: j3 N9 i; @<P> </P>4 K, T! ^3 @9 q Z
<P>Note If source refers to an SQL statement composed of a string concatenated </P> @, L. C8 Z( o& k0 k @' E/ ]" d( x; _, U
<P>with a non-integer value, and the system parameters specify a non-U.S. </P>2 ~4 [: ~7 R5 W) x* T
<P>decimal character such as a comma (for example, strSQL = "PRICE > " & </P> 2 D+ R6 {2 F, W) h( b# j<P>lngPrice, and lngPrice = 125,50), an error occurs when you try to open the </P> [/ K" N2 P9 N6 M6 v6 O<P>Recordset. This is because during concatenation, the number will be converted </P> . [! ]$ w0 {( u, T9 a' A<P>to a string using your system's default decimal character, and SQL only </P>, u" a$ U# N1 P T; K/ `
<P>accepts U.S. decimal characters.</P>