<> </P>9 B; Q" j, k+ y! n
<>Creates a new Recordset object and appends it to the Recordsets collection. </P>* N7 m1 B9 ]; z$ \
<> </P>" c$ {7 P: Q% z0 p7 c/ y0 h
<>Syntax </P>- x; u2 `. m/ V4 A
<> </P> 3 x6 j3 Q( y8 b1 v- D% m<>For Connection and Database objects: </P>1 d9 _# ~0 @3 ~! X! E
<> </P>! r6 G( N$ j4 T' p
<>Set recordset = object.OpenRecordset (source, type, options, lockedits) </P>& E* q( D7 Z1 m
<> </P>/ L- `1 t T( X$ k2 ^8 N
<>For QueryDef, Recordset, and TableDef objects: </P> ' }$ _! U2 P# z- a+ P9 Z! R<> </P> + {( x' b/ d) Z& P0 w<>Set recordset = object.OpenRecordset (type, options, lockedits) </P>% t4 o8 \1 D! V2 i- O
<> </P>' U3 ], n" l7 x# |$ M% u
<>The OpenRecordset method syntax has these parts. </P> . s: P3 r9 a! [& e5 S* ^<> </P>7 @) K% A- j" p5 z; k8 ?9 N
<>art Description </P> X8 v) `7 I5 Z- T. c( u<>recordset An object variable that represents the Recordset object you wantt to </P> 3 I" O2 K o4 K+ B5 ]. n<>open. </P>! v, i; U6 n% G/ N
<>object An object variable that represents an existing object from which you </P>& Z1 }, a8 a9 ?7 l5 m9 G6 Q
<>want to create the new Recordset. </P> - {0 Q: J" L- K% \3 I<>source A String specifying the source of the records for the new Recordset. </P> Z5 j3 Y: Z0 `+ a7 B& R5 ^7 M
<>The source can be a table name, a query name, or an SQL statement that </P> " p# e2 h# N0 f5 n<>returns records. For table-type Recordset objects in Microsoft Jet databases, </P> ' V/ o! r' x( U I( O<>the source can only be a table name. </P> % G1 h8 Y. ^8 ~: d9 e<>type Optional. A constant that indicates the type of Recordset to open, as </P> 5 {- f) Y' T/ b" w9 K, }<>specified in Settings. </P> 0 B/ w! u3 x6 f/ _. o<>options Optional. A combination of constants that specify characteristics of </P>' F2 p; N! E2 z9 D5 ~ M% s
<>the new Recordset, as listed in Settings. </P>& J1 p) y! m) ~7 E0 }% J# }% q
<>lockedits Optional. A constant that determines the locking for the Recordsset, </P>, P/ y+ [- K5 |6 X
<P>as specified in Settings. </P> / _& u0 S/ N1 `& w<P>Settings </P> / _ G0 O% r& m6 D2 L<P> </P> ! U% Y% g8 m6 [) C8 E! ^<P>You can use one of the following constants for the type argument. </P> [4 D' C1 f0 i ^3 T; ^5 N' f<P> </P>" }$ G5 T. l9 _) w
<P>Constant Description </P> 9 `" I# j) A5 J<P> </P>+ k) V L' F( O( q/ ^0 k
<P> </P>! S' o* u g: F5 s3 K/ d
<P>dbOpenTable Opens a table-type Recordset object (Microsoft Jet workspaces </P>" V* S5 G0 m3 X' }, b5 s+ o
<P>only). </P> 1 s$ E; n: i9 P' ?3 M! U<P>dbOpenDynamic Opens a dynamic-type Recordset object, which is similar to an </P> / X- q, p9 }4 K" D<P>ODBC dynamic cursor. (ODBCDirect workspaces only) </P> . y1 k* `* J! \<P>dbOpenDynaset Opens a dynaset-type Recordset object, which is similar to an </P> : h% P' U2 m1 n3 a! Y<P>ODBC keyset cursor. </P>' O% {& m' e9 b9 `. Q6 R
<P>dbOpenSnapshot Opens a snapshot-type Recordset object, which is similar to an </P>: c9 l& q5 v6 g0 t
<P>ODBC static cursor. </P> - S* [% M: W$ F1 Q3 V0 T1 C<P>dbOpenForwardOnly?Opens a forward-only-type Recordset object. </P> ' _) S6 u, u( w+ h<P>Note If you open a Recordset in a Microsoft Jet workspace and you don't </P> ! R8 ]$ ~3 s$ i" K<P>specify a type, OpenRecordset creates a table-type Recordset, if possible. If </P> $ d: S A( r3 F% C' H+ N4 z<P>you specify a linked table or query, OpenRecordset creates a dynaset-type </P> $ e' W4 V5 `! g% p' `& V<P>Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnl </P> , G( ?% v n r. |1 Q<P>y. </P>$ R9 u& Z$ u- `6 G2 P* V
<P> </P> , p; u2 w+ D2 \! P<P>You can use a combination of the following constants for the options </P> & G I' i" C, I0 ^8 ^) ~4 W<P>argument. </P> . K4 A( E. K v# N5 j: y; K( Q; L<P> </P>2 F% l( p5 }: ~- e I
<P>Constant Description </P>; q/ I/ O1 t3 @0 Q% Z8 v
<P>dbAppendOnly?Allows users to append new records to the Recordset, but </P> . t, q8 Y% ~! f, f3 o+ M<P>prevents them from editing or deleting existing records (Microsoft Jet </P> Q+ Q$ o1 V# M5 ^$ M
<P>dynaset-type Recordset only). </P>, v% G% B' ]6 A8 O5 q2 u
<P>dbSQLPassThrough?Passes an SQL statement to a Microsoft Jet-connected ODBC </P> & [$ K5 }- p" s# f" j# `% S! \<P>data source for processing (Microsoft Jet snapshot-type Recordset only). </P> 6 f' [1 r# T. r! _5 s$ N<P>dbSeeChanges Generates a run-time error if one user is changing data that </P>: S& f6 R) y8 ]) w5 u2 A
<P>another user is editing (Microsoft Jet dynaset-type Recordset only). This is </P> 4 J" }! d% n1 ?/ t<P>useful in applications where multiple users have simultaneous read/write </P> $ i e/ g5 _/ ^4 C5 A9 j) G<P>access to the same data. </P>9 ]& \6 a5 l9 @$ E9 s
<P>dbDenyWrite?Prevents other users from modifying or adding records (Microsoft </P>; ~* F# a& W X& a: l
<P>Jet Recordset objects only). </P> ! v* z& B$ c' o- @% ^1 X0 k! a+ R<P>dbDenyRead?Prevents other users from reading data in a table (Microsoft Jet </P>) s) |" ?9 v6 G) O3 I) P
<P>table-type Recordset only). </P>, q w8 X5 _3 Q2 I0 p
<P>dbForwardOnly?Creates a forward-only Recordset (Microsoft Jet snapshot-type </P>2 r8 \5 X0 b: S0 n" A3 G% ]
<P>Recordset only). It is provided only for backward compatibility, and you </P>% U, \: y* U* M" R7 Q
<P>should use the dbOpenForwardOnly constant in the type argument instead of </P>* m; \# Y7 ], Y0 q9 [
<P>using this option. </P>7 f9 K& u6 J! u3 l
<P>dbReadOnly?Prevents users from making changes to the Recordset (Microsoft Jet </P> 1 t, N: r2 \3 c! n% O<P>only). The dbReadOnly constant in the lockedits argument replaces this </P>" P: T: L" v. X$ i1 s$ T
<P>option, which is provided only for backward compatibility. </P> ! h; G3 \ B8 Q1 E<P>dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only). </P> ! k1 O" _1 l& e# ~' M<P>dbExecDirect?Runs a query by skipping SQLPrepare and directly calling </P> & e# Y4 O( h' v4 V<P>SQLExecDirect (ODBCDirect workspaces only). Use this option only when you抮e </P>( j: _" X- ^ ~1 C0 G
<P>not opening a Recordset based on a parameter query. For more information, see </P> w( [3 h5 j/ H: N3 O2 M<P>the "Microsoft ODBC 3.0 Programmer抯 Reference." </P> ! F+ s: I& q0 ?6 H) U$ c7 M<P>dbInconsistent?Allows inconsistent updates (Microsoft Jet dynaset-type and </P> 2 j/ U9 s1 p7 e* c' ?1 Y<P>snapshot-type Recordset objects only). </P>/ W" S; \# X6 a8 r
<P>dbConsistent?Allows only consistent updates (Microsoft Jet dynaset-type and </P> ( H2 S- d, V% f& q7 [( N! V<P>snapshot-type Recordset objects only). </P> 1 j: I" g$ R8 L<P>Note The constants dbConsistent and dbInconsistent are mutually exclusive, </P> * g, v/ [5 C2 e7 X( V: E9 n4 p<P>and using both causes an error. Supplying a lockedits argument when options </P>- I/ R: M2 z& i- X/ ]; v& i
<P>uses the dbReadOnly constant also causes an error. </P>" A4 ?. ~$ _# L8 \: O- Q' N
<P> </P> 5 {' o' m$ M! ^<P>You can use the following constants for the lockedits argument. </P> # J" x% a5 [) t; d<P> </P>2 }0 Y) B& H6 } y' c0 ]$ [
<P>Constant Description </P>. O% I8 {& R Z7 v2 w
<P>dbReadOnly Prevents users from making changes to the Recordset (default for </P> 0 ]: g y2 O( K: Y4 q# }5 q2 I: ^9 a<P>ODBCDirect workspaces). You can use dbReadOnly in either the options argument </P>* X' u* F% h: i# q: Y% V" U
<P>or the lockedits argument, but not both. If you use it for both arguments, a </P> 2 F' n4 E' e/ S, Z/ U" d0 H<P>run-time error occurs. </P> 0 \$ P. d+ V$ @& W<P>dbPessimistic?Uses pessimistic locking to determine how changes are made to </P>" b2 m q; M+ M) ]8 b; f9 J
<P>the Recordset in a multiuser environment. The page containing the record </P>) j4 u) w0 U2 E8 @: b; P! F' B
<P>you're editing is locked as soon as you use the Edit method (default for </P>. Z# f, u9 I S! W. I+ Q9 I2 ~
<P>Microsoft Jet workspaces). </P>7 l7 }, j$ t7 G3 n
<P>dbOptimistic?Uses optimistic locking to determine how changes are made to the </P> e$ ^9 }" u/ n5 M x$ p<P>Recordset in a multiuser environment. The page containing the record is not </P>8 I( K! C& L1 d4 y! w; p
<P>locked until the Update method is executed. </P>' I/ [! O4 F. [% P3 x# g
<P>dbOptimisticValue?Uses optimistic concurrency based on row values (ODBCDirect </P>' ~) D6 d- u& q( k- ]6 f
<P>workspaces only). </P>2 E# m4 w/ k D( P
<P>dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect workspaces </P> 8 O' E; }# }) X' f; h: ]. z<P>only). </P> U: F* C. [" q# }) A1 K+ G
<P>Remarks </P>- K! Q$ T4 k8 `1 t' x( [
<P> </P> % i" R) ]( b' y5 Y4 v$ X<P>In a Microsoft Jet workspace, if object refers to a QueryDef object, or a </P> ' W1 H+ e& J# i6 L: O, }<P>dynaset- or snapshot-type Recordset, or if source refers to an SQL statement </P> . e* A' A6 F1 ?2 Y<P>or a TableDef that represents a linked table, you can't use dbOpenTable for </P>% b# I3 t p {8 R# A& L
<P>the type argument; if you do, a run-time error occurs. If you want to use an </P>3 g: D) v/ r y r+ T7 k
<P>SQL pass-through query on a linked table in a Microsoft Jet-connected ODBC </P>9 k4 F/ O, Y3 I5 q
<P>data source, you must first set the Connect property of the linked table's </P>6 D, E* x6 @% B' p+ y' D- B! \) i
<P>database to a valid ODBC connection string. If you only need to make a single </P>4 y$ N+ N6 _* S9 Q1 d" |
<P>pass through a Recordset opened from a Microsoft Jet-connected ODBC data </P> ; T; a5 E" E9 W/ } j* @<P>source, you can improve performance by using dbOpenForwardOnly for the type </P> , d: P0 G3 N+ Q% z7 A<P>argument. </P>+ ?4 M% y* n* n
<P> </P>; ?' G6 J9 x3 Z& O) a: \
<P>If object refers to a dynaset- or snapshot-type Recordset, the new Recordset </P>1 @7 P2 G, R5 \* V2 u2 G
<P>is of the same type object. If object </P>$ e; `2 C4 b4 O* J
<P> refers to a table-type Recordset object, the type of the new object is a </P> 4 w7 O% B/ Y" V: F4 f" C) M6 j3 S<P>dynaset-type Recordset. You can't open new Recordset objects from forward-only </P> 6 f# Z. L) u6 p+ ?3 h<P>杢ype or ODBCDirect Recordset objects. </P> p4 n2 J6 H) q K
<P>In an ODBCDirect workspace, you can open a Recordset containing more than one </P>. Q. q/ J k1 a( ?3 h
<P>select query in the source argument, such as </P> 2 n E; ^0 `8 @2 K2 ]<P> </P>" y& n, `, [& ~- U- ~) o7 ^
<P>"SELECT LastName, FirstName FROM Authors </P>, X% e7 V& |' q5 _4 s2 c
<P>WHERE LastName = 'Smith'; </P>% j; X7 X. s) r5 w0 [! W
<P>SELECT Title, ISBN FROM Titles </P>! X7 x! k; k5 v. M/ j
<P>WHERE ISBN Like '1-55615-*'" </P>) D( Y( P; I, z) u! {: g
<P> </P>$ a7 f' v+ U( |5 {4 P5 N" `5 C
<P>The returned Recordset will open with the results of the first query. To </P>* ?0 V) ~7 s. N. ]
<P>obtain the result sets of records from subsequent queries, use the </P>2 Z, r# N6 W# S$ J) J! V; `6 V
<P>NextRecordset method. </P>& u- ^5 K" P& m2 | z/ e1 I4 R
<P> </P>2 ^1 O; v6 u- v! G: Y
<P>Note You can send DAO queries to a variety of different database servers </P> 7 r6 X3 r; I6 H/ w$ q<P>with ODBCDirect, and different servers will recognize slightly different </P> $ h) D/ l$ }3 w! P<P>dialects of SQL. Therefore, context-sensitive Help is no longer provided for </P> . {) ]" j: A4 |; z5 J7 Y- x, D- ^<P>Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still </P>8 D7 q2 [; ?0 Q/ f9 D* |
<P>included through the Help menu. Be sure to check the appropriate reference </P> - s3 X1 o' f4 D% [" @" H<P>documentation for the SQL dialect of your database server when using either </P> 9 u" o6 C! f# @+ a% T5 c/ A! n' k<P>ODBCDirect connections or pass-through queries in Microsoft Jet-connected </P>0 n$ ]% Q$ v( I3 n& D D
<P>client/server applications. </P> 1 \, R5 D2 S; u7 F<P> </P>8 e/ F9 T' s0 p
<P>Use the dbSeeChanges constant in a Microsoft Jet workspace if you want to </P> 0 x/ h/ f" P8 \0 j6 M<P>trap changes while two or more users are editing or deleting the same record. </P>( t, \; ^8 ^$ n# V% I/ W
<P>For example, if two users start editing the same record, the first user to </P># t( F9 s, D; G5 H! S
<P>execute the Update method succeeds. When the second user invokes the Update </P>. o, F, U! O; p6 s1 ?3 R
<P>method, a run-time error occurs. Similarly, if the second user tries to use </P> ) w) o$ Z& `8 m9 O& A' [3 D* N<P>the Delete method to delete the record, and the first user has already </P> , R" T9 j. V* \3 C<P>changed it, a run-time error occurs. </P>) |4 y* p- v J0 P
<P> </P> , o4 O4 ^ A, H1 H9 h* n: F* K. j<P>Typically, if the user gets this error while updating a record, your code </P>' z L$ g1 t* Q# |
<P>should refresh the contents of the fields and retrieve the newly modified </P>1 p0 ?# q+ k2 o8 y5 c4 f6 y R9 C# I
<P>values. If the error occurs while deleting a record, your code could display </P>2 t" n" m5 U2 O+ G" @: U
<P>the new record data to the user and a message indicating that the data has </P>7 }: s& G) @2 {' h8 B' ?/ G
<P>recently changed. At this point, your code can request a confirmation that </P> ( A" D4 J' H- j I5 T; F<P>the user still wants to delete the record. </P> 3 O5 R& t; g; B$ S! M<P> </P> ( {0 O$ h# V/ {) T<P>You should also use the dbSeeChanges constant if you open a Recordset in a </P>5 r H; N! ?3 x1 S& ^, P5 P
<P>Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server 6.0 (or </P> $ ^) t1 _) E4 \! }# T0 \<P>later) table that has an IDENTITY column, otherwise an error may result. </P>2 n' K8 f+ r9 S L# J
<P> </P> 4 _0 N' N% F$ S, c2 T<P>In an ODBCDirect workspace, you can execute asynchronous queries by setting </P>+ o0 b7 \) Z# L; a. T
<P>the dbRunAsync constant in the options argument. This allows your application </P>2 c, D8 X1 D+ Y% x1 Z5 Y
<P>to continue processing other statements while the query runs in the </P>+ e% H- w9 X: H# w5 t
<P>background. But, you cannot access the Recordset data until the query has </P>2 _2 O: i# L4 _: ~/ B& g
<P>completed. To determine whether the query has finished executing, check the </P> 0 x: ^( u$ i p7 X: P1 {<P>StillExecuting property of the new Recordset. If the query takes longer to </P> ' f q" |5 o# Q" ~<P>complete than you anticipated, you can terminate execution of the query with </P>) G# i, ]0 P. |% d
<P>the Cancel method. </P>5 O* V% M+ d7 b# t0 {1 i
<P> </P># i* V* I3 \- m/ a& ]
<P>Opening more than one Recordset on an ODBC data source may fail because the </P> 7 v) C6 S2 D& [ e<P>connection is busy with a prior </P> E" b) J6 R) b0 h<P>OpenRecordset call. One way around this is to use a server-side cursor and </P>$ M% _/ Z2 Y6 X/ H W
<P>ODBCDirect, if the server supports this. Another solution is to fully </P>7 X7 ]% I: O7 |1 l
<P>populate the Recordset by using the MoveLast method as soon as the Recordset </P># z* | I# e" Q2 B/ D
<P>is opened. </P> ( N/ u( S( \# N$ N7 s<P> </P> & O5 }/ F: |1 a Q9 ?3 ^; S$ Q<P>If you open a Connection object with DefaultCursorDriver set to </P> * R& s+ G X; o: G0 |<P>dbUseClientBatchCursor, you can open a Recordset to cache changes to the data </P> # T7 [, M. n) e( x6 p9 u<P>(known as batch updating) in an ODBCDirect workspace. Include dbOptimisticBatc </P> S# o# V0 d/ y, k/ I# |<P>h in the lockedits argument to enable update caching. See the Update method </P> 9 r# m$ D- F, q& C) r% s- ^<P>topic for details about how to write changes to disk immediately, or to cache </P>- f9 N( z0 T+ {) v% G0 ?$ E
<P>changes and write them to disk as a batch. </P>2 O# o; y& f) ?) D5 n7 ?( k
<P> </P> + x7 k; x+ p; T1 O0 e6 N<P>Closing a Recordset with the Close method automatically deletes it from the </P> " i8 x; C' O! a& A8 z' _ 2 [: C, \9 i1 I, O8 D# g<P>Recordsets collection. </P> 3 f$ P8 {1 o3 |& ~ n8 A<P> </P>3 k; I: X" J' C! w5 w
<P>Note If source refers to an SQL statement composed of a string concatenated </P>2 ]# b9 |7 o/ ^5 S; `
<P>with a non-integer value, and the system parameters specify a non-U.S. </P>! H/ D" k7 x% t* S+ n% a
<P>decimal character such as a comma (for example, strSQL = "PRICE > " & </P>0 `+ k3 ~- f, {0 @# F
<P>lngPrice, and lngPrice = 125,50), an error occurs when you try to open the </P> 8 a; S! b* @6 }& t" h* g<P>Recordset. This is because during concatenation, the number will be converted </P>; M# T, f( q; p" M- Y
<P>to a string using your system's default decimal character, and SQL only </P>9 h ]3 f0 t9 R" ] T" O
<P>accepts U.S. decimal characters.</P>