Recordsets

Recordsets are used to manipulate data in Access databases; they represent the records in tables or queries in a database. There are five types of DAO recordsets, with different properties, as described in the following sections. Specify the recordset type by using the appropriate constant for the type argument when creating a recordset, as in the following code:

Set rst = dbs.OpenRecordset(Name:="tblOrders", _ Type:=dbOpenDynaset)

Table 5.3 lists the named constants corresponding to the five recordset types (and their numeric equivalents). These named constants are used in VBA code; some dialects of Visual Basic, such as

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.

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.

0 0

Post a comment