VBScript (VBS), don’t support named constants, so you need to use the numeric values instead, for
example when writing Outlook VBS code or Windows Script Host (WSH) code.
See Chapter 17 for examples of WSH code.
TABLE 5.3
DAO Recordset Type Named Arguments
Recordset Type Named Constant Numeric Value
Table dbOpenTable 1
Dynaset dbOpenDynaset 2
Snapshot dbOpenSnapshot 4
Forward-only dbOpenForwardOnly 8
Dynamic dbOpenDynamic 16
If you don’t specify a recordset type, DAO assumes first that you intend to create a table-type
recordset, and if that is impossible, then a dynaset, then a snapshot, then a forward-only recordset.
The table- and dynaset-type recordsets are the most commonly used types.
Table
Table-type recordsets represent base tables (that is, tables located within the database from which
the code is running, as opposed to linked tables). You can add, edit, or delete records from a table
using a table-type recordset. These recordsets don’t support the Findmethods (FindFirst,
FindLast, FindNext, FindPrevious); instead they support the Seekmethod.
To run one of the procedures in the DAO and ADO Sample Code database, place your
cursor inside the procedure and press F5, or select Run Sub/UserForm from the Run
menu in the Visual Basic window.
If you don’t get a response when pressing a function key, function keys may be disabled;
some newer keyboards disable function keys by default. To enable function keys, press
the F Lock key.
The following code segment searches for the record with a specific value (retrieved from an
InputBox) in the CompanyID field and, if it is found, displays the value in the ID/AccountNumber
field for that record in a message box:
Private Sub ListID()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
TIPTIP
NOTENOTE
CROCROSSSS-REF-REF
Part II Writing VBA Code to Exchange Data between Office Components