Microsoft Office Tutorials and References
In Depth Information
Chapter 5: Using SQL and Recordsets
The code in Figure 5-2 isn’t exactly simple. The sections that follow,
however, shed some light on some of its meanings.
Flip to Chapter 3 of this minibook for details on While...Wend loops.
Defining a recordset’s cursor type
When you open a table in Datasheet or Form view, you see the blinking
cursor, and you can use your mouse or keyboard to move it around freely. In
recordsets, you can choose among different types of cursors. The cursor is a
pointer to the current record in the recordset. The type of cursor has
nothing to do with how the cursor looks, because in a recordset, you can’t see
the cursor (or the data)! Rather, the cursor type in a recordset defines how
the cursor behaves within the recordset.
You can define a recordset’s cursor type in two ways:
Change the recordset’s CursorType property by using the following
recordsetName .CursorType = constant
recordsetName is the name of the recordset, and constant is one of
the constants listed in the first column of Table 5-1.
You must define the recordset’s cursor type before opening a recordset.
Specify the cursor type when opening the recordset by using this syntax:
myRecordset .Open “ tableName/SQL ”, , CursorType
tableName/SQL is the name of the table in the current database or a
valid SQL statement (which we discuss in a moment), and CursorType
is one of the constants listed in Table 5-1.
Many cursor type options are relevant only to multiuser databases. When
you’re working with a single-user database, the adOpenStatic setting is the
easiest to work with.
Table 5-1
Recordset Cursor Types
This constant allows unrestricted cursor movement.
You can modify data in the recordset. Changes
made by other users in a multiuser setting are
reflected in the recordset.
The recordset is a nonchanging version of the
table. Changes made by other users have no
effect on the recordset.
Search JabSto ::

Custom Search