<> </P>. _0 t4 g4 B+ K* W
<>Creates a new Recordset object and appends it to the Recordsets collection. </P> 1 F& ?4 S T* a+ d) E2 Y, K+ s G<> </P>3 R2 S* t, C$ Q0 V6 b* D
<>Syntax </P> 9 [# W- l+ q: T. K7 _<> </P> + U* D, Y: C7 b& q; d& B<>For Connection and Database objects: </P>! ^! U v( l$ ]% B6 \
<> </P>$ B9 |+ A. t" Q2 [
<>Set recordset = object.OpenRecordset (source, type, options, lockedits) </P> 9 Z6 m5 ?0 C, F5 r$ N<> </P>& D) y2 d) f- T" T c! i {
<>For QueryDef, Recordset, and TableDef objects: </P>9 R3 [! d6 s* ?1 I
<> </P>- U: r. e9 K6 [+ T4 n
<>Set recordset = object.OpenRecordset (type, options, lockedits) </P>3 k4 o# N$ V) z `+ _2 y
<> </P>+ p5 e2 h7 K9 f. r4 [
<>The OpenRecordset method syntax has these parts. </P>7 m0 {: u5 G% O% h# Y
<> </P>! A, f) E) P/ T) B$ H3 y' _( i& m
<>art Description </P> * g" [( A+ z6 r6 d, o<>recordset An object variable that represents the Recordset object you wantt to </P>6 R: e, y' P( [# k5 z
<>open. </P> , L. ^) K3 n4 Z$ G, _3 t2 Y7 M% `3 ~ V<>object An object variable that represents an existing object from which you </P> * i4 x7 {" _7 S4 z: r- ^* w$ O- S: s<>want to create the new Recordset. </P> # z- B& p* s) Q) v<>source A String specifying the source of the records for the new Recordset. </P> * ?5 d! A* n w- h<>The source can be a table name, a query name, or an SQL statement that </P> , O, a8 |4 j, K' K- ?<>returns records. For table-type Recordset objects in Microsoft Jet databases, </P> 4 c- B) U& I- r) s0 d! Q( O<>the source can only be a table name. </P>2 ]1 U1 i# f, Q4 J
<>type Optional. A constant that indicates the type of Recordset to open, as </P> + X# m% }) ?# _/ I- T<>specified in Settings. </P> , \# H2 k; M1 {<>options Optional. A combination of constants that specify characteristics of </P>% W8 U5 E2 i7 z9 O# J
<>the new Recordset, as listed in Settings. </P> ( m. \$ e; n' a1 R+ F" _<>lockedits Optional. A constant that determines the locking for the Recordsset, </P>. I7 A/ w4 y& e% h
<P>as specified in Settings. </P> + Y5 t. U7 Z! z" o/ Y% y `0 k<P>Settings </P> 7 j4 y- B N8 F! `<P> </P> / Q3 U" j# r8 X8 K! O" L- {<P>You can use one of the following constants for the type argument. </P> + i6 t8 ?% C6 n/ X<P> </P> : O8 h, n! F7 M" g5 D7 r<P>Constant Description </P> # b- g* T9 F3 Q! Q2 t3 }: e2 T! z<P> </P>. q) C I4 a$ J( M) b
<P> </P>2 Z; P8 J" |# J$ @
<P>dbOpenTable Opens a table-type Recordset object (Microsoft Jet workspaces </P> ( T: Y6 F2 q% e; a! \<P>only). </P> $ O' ^; v2 P7 N: l+ R<P>dbOpenDynamic Opens a dynamic-type Recordset object, which is similar to an </P> 1 ~5 B( u( |1 \" e9 H3 K/ w<P>ODBC dynamic cursor. (ODBCDirect workspaces only) </P> ; ] D. m; I6 Z' k% W7 ^<P>dbOpenDynaset Opens a dynaset-type Recordset object, which is similar to an </P>0 {/ L5 B7 ^% R3 ~3 d. V, [" }& m
<P>ODBC keyset cursor. </P> 8 M. {6 M4 v. Y8 G5 r; t% w9 D<P>dbOpenSnapshot Opens a snapshot-type Recordset object, which is similar to an </P> 1 N L- \9 I, R6 Z& @<P>ODBC static cursor. </P>" C2 l F& c/ A$ O( B a) u
<P>dbOpenForwardOnly?Opens a forward-only-type Recordset object. </P> 0 ]3 s4 ^; X: X) ^, P<P>Note If you open a Recordset in a Microsoft Jet workspace and you don't </P>8 b2 l: P A' c/ t( z0 H, C0 @/ N
<P>specify a type, OpenRecordset creates a table-type Recordset, if possible. If </P>6 i& _% E" Z3 G
<P>you specify a linked table or query, OpenRecordset creates a dynaset-type </P> ' W+ s( ~6 b. x: x* }6 i<P>Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnl </P> 1 h- ]& _$ u \<P>y. </P>' P, t( z2 ^8 d* b4 O5 J" Q
<P> </P> % e' |3 J2 q& ?1 p<P>You can use a combination of the following constants for the options </P>$ j) D, o1 d$ |' t; K1 S5 X
<P>argument. </P> * q* d0 f* k3 E& }, C6 b! s<P> </P>. x1 M% P. F% `% `4 m
<P>Constant Description </P>( S6 W& u2 h5 H% x) g2 J
<P>dbAppendOnly?Allows users to append new records to the Recordset, but </P>0 h9 g0 t2 M, Y! U0 L3 O
<P>prevents them from editing or deleting existing records (Microsoft Jet </P> Z4 `3 J) }2 s/ E
<P>dynaset-type Recordset only). </P> 4 P( C* i( R8 R( H+ |! k* K+ a<P>dbSQLPassThrough?Passes an SQL statement to a Microsoft Jet-connected ODBC </P> 9 ^% T% E- Y# Y; \2 o* {<P>data source for processing (Microsoft Jet snapshot-type Recordset only). </P> 6 ?5 a( z* z/ _7 A<P>dbSeeChanges Generates a run-time error if one user is changing data that </P>! Q, l% q) V: P+ |
<P>another user is editing (Microsoft Jet dynaset-type Recordset only). This is </P>9 @& W& R \. s& e& L0 m5 i
<P>useful in applications where multiple users have simultaneous read/write </P>% y- r! H' I# P7 d& c) D
<P>access to the same data. </P> 4 ]% r/ g4 g( X8 c# P. V; q<P>dbDenyWrite?Prevents other users from modifying or adding records (Microsoft </P> l+ h0 \! g( x* u
<P>Jet Recordset objects only). </P> $ C! K! j' |7 n. c1 b<P>dbDenyRead?Prevents other users from reading data in a table (Microsoft Jet </P>( e8 A2 d! v. r9 ?% }
<P>table-type Recordset only). </P>( q; k- w0 p. s( j$ O
<P>dbForwardOnly?Creates a forward-only Recordset (Microsoft Jet snapshot-type </P> & z: g' D( J2 D. t B7 H<P>Recordset only). It is provided only for backward compatibility, and you </P>% R9 r B. G* R( o1 t* i
<P>should use the dbOpenForwardOnly constant in the type argument instead of </P> 6 H x- m& t+ x: M C( p: k<P>using this option. </P>7 a! F6 o$ \- b" o) G$ F0 {" e0 l8 f
<P>dbReadOnly?Prevents users from making changes to the Recordset (Microsoft Jet </P>5 ?5 O) Q4 C- U( ^. u
<P>only). The dbReadOnly constant in the lockedits argument replaces this </P>, L2 u0 Y+ \3 v, B' @
<P>option, which is provided only for backward compatibility. </P>/ U- p/ K1 I' Q# r
<P>dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only). </P> / w- |. q3 B0 O& @: U7 m<P>dbExecDirect?Runs a query by skipping SQLPrepare and directly calling </P>7 d, Y7 x8 ^ N" _/ V! }) P
<P>SQLExecDirect (ODBCDirect workspaces only). Use this option only when you抮e </P> * M4 C1 ?, I: Q/ F( N4 ]: |" x<P>not opening a Recordset based on a parameter query. For more information, see </P> ! X* ^: D( g: {! g. m+ y<P>the "Microsoft ODBC 3.0 Programmer抯 Reference." </P> ( P0 |6 B) s2 c<P>dbInconsistent?Allows inconsistent updates (Microsoft Jet dynaset-type and </P> 2 l {0 @) [0 f2 O0 K6 M; _+ J) l<P>snapshot-type Recordset objects only). </P> % {/ z" d: u' D* R5 C<P>dbConsistent?Allows only consistent updates (Microsoft Jet dynaset-type and </P>( e9 c4 x( L: @" r
<P>snapshot-type Recordset objects only). </P> ( W+ @1 p( O$ R. h; g<P>Note The constants dbConsistent and dbInconsistent are mutually exclusive, </P> ; y0 X1 s5 E% c& _/ x$ e$ y<P>and using both causes an error. Supplying a lockedits argument when options </P> 0 r$ h* ?8 L, \/ ?6 j& t<P>uses the dbReadOnly constant also causes an error. </P> , {: B& h6 H# U6 w; g) e8 ]<P> </P>( ?8 P+ @3 M, a+ Q* h% P
<P>You can use the following constants for the lockedits argument. </P>: B+ f4 o: v5 {( }4 b1 m; j
<P> </P>4 }4 B& e3 n5 h% E& b' o4 _) O3 n
<P>Constant Description </P> " a1 g. Z( x5 V+ _5 X% j* f<P>dbReadOnly Prevents users from making changes to the Recordset (default for </P>) t' ]! r9 T, C% {; P/ J
<P>ODBCDirect workspaces). You can use dbReadOnly in either the options argument </P>. S" S' j. U% }5 Q+ [% M
<P>or the lockedits argument, but not both. If you use it for both arguments, a </P> U# a+ X- q" c ~: n1 w
<P>run-time error occurs. </P>0 b1 b* ]: _ ]3 g
<P>dbPessimistic?Uses pessimistic locking to determine how changes are made to </P> 6 P1 [$ F/ ~% f/ o% {, j: Y<P>the Recordset in a multiuser environment. The page containing the record </P> ; z9 l# ?* H2 O1 h<P>you're editing is locked as soon as you use the Edit method (default for </P>. W- c3 K: f7 n
<P>Microsoft Jet workspaces). </P>& M) |) l. |- l6 L% N8 p
<P>dbOptimistic?Uses optimistic locking to determine how changes are made to the </P> + i$ P Y2 B+ M) w<P>Recordset in a multiuser environment. The page containing the record is not </P> 9 o* L) f0 u# w) s) f+ E, y. t3 f, U<P>locked until the Update method is executed. </P>7 B1 B* j* G% K, _5 S: C
<P>dbOptimisticValue?Uses optimistic concurrency based on row values (ODBCDirect </P>' V+ ]3 Y" {8 s' l$ S% b
<P>workspaces only). </P> : o) L$ Q1 U8 S; T4 q9 D0 q<P>dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect workspaces </P> 6 O' K8 ~1 g5 G: @( n<P>only). </P> 4 R% ?& w2 K& ~<P>Remarks </P>8 A- k5 r/ {3 X1 F6 f5 }
<P> </P> - e* s" u; a9 U7 a" m6 A# g3 B<P>In a Microsoft Jet workspace, if object refers to a QueryDef object, or a </P> : ^; C& l; m1 Z/ g! u" H* }<P>dynaset- or snapshot-type Recordset, or if source refers to an SQL statement </P>6 f- w/ z0 w _$ L. J# z
<P>or a TableDef that represents a linked table, you can't use dbOpenTable for </P>. \+ i; Y2 m0 U$ c3 [' h$ A
<P>the type argument; if you do, a run-time error occurs. If you want to use an </P> . x( V9 B& f. c b. s7 V<P>SQL pass-through query on a linked table in a Microsoft Jet-connected ODBC </P> ) N9 J. y7 i' Z& Y9 j- h<P>data source, you must first set the Connect property of the linked table's </P>0 z8 @7 R6 }( ?: f: x4 M) O
<P>database to a valid ODBC connection string. If you only need to make a single </P> 3 ^ k- [ h0 s<P>pass through a Recordset opened from a Microsoft Jet-connected ODBC data </P>$ p4 R/ l, G% I1 j; W
<P>source, you can improve performance by using dbOpenForwardOnly for the type </P>& I2 _9 ^& W2 b+ ~+ |3 N
<P>argument. </P>* c2 b2 _" X0 I7 d2 A9 A8 b! L
<P> </P> 3 k! O; N6 J8 v$ l* M<P>If object refers to a dynaset- or snapshot-type Recordset, the new Recordset </P> - h( W! P3 q: O) S2 {<P>is of the same type object. If object </P> , Y$ g0 B0 r% N<P> refers to a table-type Recordset object, the type of the new object is a </P> / A, L/ p! y/ [2 d( ^<P>dynaset-type Recordset. You can't open new Recordset objects from forward-only </P> E2 p1 f5 m5 i" y! @% ? x; F
<P>杢ype or ODBCDirect Recordset objects. </P> 4 p, B/ {7 u; c. F; r) G<P>In an ODBCDirect workspace, you can open a Recordset containing more than one </P>( Q( s0 Q3 Q0 \& q
<P>select query in the source argument, such as </P> 2 W/ w6 T* o4 g; z) a9 r8 `<P> </P>) L8 h5 K+ ]. h; F8 T8 n1 f
<P>"SELECT LastName, FirstName FROM Authors </P> O. l% I# O m) @: r<P>WHERE LastName = 'Smith'; </P>' j: X3 D& _) c2 K s' m
<P>SELECT Title, ISBN FROM Titles </P> ' H* w0 e5 G+ K7 E8 x<P>WHERE ISBN Like '1-55615-*'" </P> 2 U3 `! X3 v$ l/ A<P> </P>, z7 ], t& A3 E7 \/ L
<P>The returned Recordset will open with the results of the first query. To </P> + B! M$ ~( u8 H<P>obtain the result sets of records from subsequent queries, use the </P>- f F2 e- [) F, l5 i/ y7 J% Y d
<P>NextRecordset method. </P>0 D" p f) h6 y$ o! x( ~2 m" {) m
<P> </P>- a0 c, d2 k' R9 ^
<P>Note You can send DAO queries to a variety of different database servers </P>2 o$ [7 z- u" G1 ]7 L4 z
<P>with ODBCDirect, and different servers will recognize slightly different </P> ; o8 c' p, G+ E! y) @<P>dialects of SQL. Therefore, context-sensitive Help is no longer provided for </P> - c/ L, Q; ?2 E9 _6 z" D; C<P>Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still </P> ) E; r8 {2 A. S) ~( l7 r1 M<P>included through the Help menu. Be sure to check the appropriate reference </P>$ `' M/ ?7 Q; J+ Z6 n' h- S
<P>documentation for the SQL dialect of your database server when using either </P>! H2 E' }- j1 W, ?5 i* z
<P>ODBCDirect connections or pass-through queries in Microsoft Jet-connected </P> " i6 j! r' P3 E6 N- b% w7 y [<P>client/server applications. </P> 5 c8 s9 U& d0 ~! H4 i/ K<P> </P>6 C" n' I q; W0 N6 h7 }
<P>Use the dbSeeChanges constant in a Microsoft Jet workspace if you want to </P> * a" L, P8 [5 Q/ G9 ]+ T% F<P>trap changes while two or more users are editing or deleting the same record. </P> ) { Z* A; |$ u' \! l<P>For example, if two users start editing the same record, the first user to </P> 5 n% Q' Z2 N3 |+ x0 X6 O<P>execute the Update method succeeds. When the second user invokes the Update </P> : i c# G4 n7 A( a6 P" Q<P>method, a run-time error occurs. Similarly, if the second user tries to use </P># i/ N& O7 ?$ b: V
<P>the Delete method to delete the record, and the first user has already </P> O/ @- z2 ?1 x5 J
<P>changed it, a run-time error occurs. </P> ; b! m# p- T1 ~1 w8 O+ k<P> </P> 8 }) u& d* y# y% u- M6 G' G' @<P>Typically, if the user gets this error while updating a record, your code </P> + L8 D9 G/ \% e. ^8 m<P>should refresh the contents of the fields and retrieve the newly modified </P>- v8 |& v/ z0 }/ D# c7 I+ v- m+ F
<P>values. If the error occurs while deleting a record, your code could display </P>; S8 [! O: r( f: ]% Q9 v
<P>the new record data to the user and a message indicating that the data has </P>* m4 C& W$ c. R/ l0 K6 C- N
<P>recently changed. At this point, your code can request a confirmation that </P> + ~. T$ }& U. {<P>the user still wants to delete the record. </P>7 E8 g5 o/ j' a/ s) h( o
<P> </P>; `; a, a* U& b0 o3 ~$ W
<P>You should also use the dbSeeChanges constant if you open a Recordset in a </P>: _. C+ M- o9 d$ T5 r1 l; S% \
<P>Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server 6.0 (or </P> 7 W9 @7 ^, y9 u8 Q3 d- u<P>later) table that has an IDENTITY column, otherwise an error may result. </P> " `1 Z" M. q6 p<P> </P>* X( E+ U' T# Y( E- s, x6 a
<P>In an ODBCDirect workspace, you can execute asynchronous queries by setting </P>% n" f, o- T2 i
<P>the dbRunAsync constant in the options argument. This allows your application </P>9 Q7 v" G' p- S
<P>to continue processing other statements while the query runs in the </P> 4 U" ~7 o$ _% k+ n5 s- C<P>background. But, you cannot access the Recordset data until the query has </P>: s* ]5 N5 Y$ [0 X
<P>completed. To determine whether the query has finished executing, check the </P> 4 @) J$ O$ {6 T8 [ _<P>StillExecuting property of the new Recordset. If the query takes longer to </P>1 P- Q. c( o) A+ p9 s( m3 Q, N/ ?
<P>complete than you anticipated, you can terminate execution of the query with </P>) ] M9 i; o3 p3 v' j- e
<P>the Cancel method. </P>6 Y( N c& P; X' |1 {
<P> </P> * z/ K9 e3 L/ K* R2 O& l4 B<P>Opening more than one Recordset on an ODBC data source may fail because the </P> - _1 B8 u5 L( Z# O$ I<P>connection is busy with a prior </P> ( G) f2 a7 I* N: _2 V4 V# X<P>OpenRecordset call. One way around this is to use a server-side cursor and </P> ! ?/ Q( G4 U2 \5 }% j( @8 y K<P>ODBCDirect, if the server supports this. Another solution is to fully </P> # s* k! d# V8 {9 p/ `' |8 d<P>populate the Recordset by using the MoveLast method as soon as the Recordset </P> 3 I. {$ d8 C- Y/ f! D5 v<P>is opened. </P> ; Y% H* }( ~# l" n! Q<P> </P> 9 {( j6 W; P# N' l( C<P>If you open a Connection object with DefaultCursorDriver set to </P> . E& ~2 _: c* f$ r b<P>dbUseClientBatchCursor, you can open a Recordset to cache changes to the data </P> 7 V! S( j1 F, W# A3 ^<P>(known as batch updating) in an ODBCDirect workspace. Include dbOptimisticBatc </P>: b D- ^2 H2 o) D, a
<P>h in the lockedits argument to enable update caching. See the Update method </P>; f& h& Y& i& c v# n
<P>topic for details about how to write changes to disk immediately, or to cache </P> & c( `" t+ B9 I5 k; d! J8 m<P>changes and write them to disk as a batch. </P> ' V, q7 c( M! i5 a! ?' `<P> </P>7 @# s9 H3 ]1 @# P. j. h
<P>Closing a Recordset with the Close method automatically deletes it from the </P> 3 X5 S5 ~: _# R( j# L6 K- r8 m) ?
<P>Recordsets collection. </P> + V% `; S/ R- F, Q<P> </P> + L. m( X( l3 T: _! b<P>Note If source refers to an SQL statement composed of a string concatenated </P>- ^# M+ K% `( w" [7 I/ r
<P>with a non-integer value, and the system parameters specify a non-U.S. </P> $ B+ @: ?( \4 p' O* E0 Q: w<P>decimal character such as a comma (for example, strSQL = "PRICE > " & </P> 2 ?& e4 ]( p; q n; M<P>lngPrice, and lngPrice = 125,50), an error occurs when you try to open the </P>3 i3 R$ L- F# a7 @, q5 c2 S4 p+ J
<P>Recordset. This is because during concatenation, the number will be converted </P> 8 v4 e- n$ ]! j. O+ n<P>to a string using your system's default decimal character, and SQL only </P>0 Y. V8 J+ I3 S' [0 f% G# G; t8 r
<P>accepts U.S. decimal characters.</P>