Access.2007.VBA.Bibl..

(John Hannent) #1
TABLE 5.6 (continued)
Cursor Type Named Constant Lock Type Named Constant Available Methods

adOpenStatic AdLockOptimistic AddNew
(converts to adOpenKeyset) Delete
Find
MoveFirst
MovePrevious
MoveNext
MoveLast
Update
adOpenStatic AdLockReadOnly Find
MoveFirst
MovePrevious
MoveNext
MoveLast
adOpenForwardOnly AdLockOptimistic AddNew
(converts to adOpenKeyset) Delete
Find
MoveFirst
MovePrevious
MoveNext
MoveLast
Update
adOpenForwardOnly AdLockReadOnly Find
MoveFirst
MoveNext
MoveLast

Dynamic

A dynamic cursor (DAO equivalent: dbOpenDynaset) lets you view additions, changes, or
deletions made by other users. All types of movement through the recordset are allowed.

Keyset

In a recordset with a keyset cursor (there is no equivalent DAO recordset type), you can add,
change, and delete data in records, but you can’t see records that other users add or delete.
However, you can see changes made by other users. With an optimistic (adLockOptimistic)
lock type, you can modify the data; if you don’t need to modify the data, use a read-only lock type
(adLockReadOnly) for faster data access.

The following TestKeysetOptimisticprocedure adds a new record to the tlkpCategories
table, and sets the value of a field from input provided by the user, after checking whether the cate-
gory name provided by the user has already been used:

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf