Referencing Objects

The first step in understanding the objects in the DAO and Microsoft Access object hierarchies is to understand how to refer to an object in the hierarchy. In particular, we can refer to an object by the name of ObjectName that belongs to a collection named CollectionName, by any of the following syntaxes:

  • CollectionName!ObjectName, or CollectionName![ObjectName] when ObjectName has illegal characters, such as spaces.

  • CollectionName(“ObjectName”).

  • CollectionName(StringVar), where StringVar holds the string ObjectName.

  • CollectionName(Index), where Index is the index number of the object in the collection. Indexes start with and go up to one less than the number of objects in the collection. (As we will see, the number of elements in a collection is denoted by CollectionName.Count.)

For instance, the TableDef object named BOOKS in the TableDefs collection is denoted by:





Dim strBooks as String
strBooks = "BOOKS"

or, if BOOKS happens to be the first TableDef object in the TableDefs collection:


The exclamation point (!) used in the first syntax is called the bang operator .

Fully Qualified Object Names

There is a problem with these names. For instance, to which object does Fields(0) refer? There are several Fields collections in the DAO hierarchy, as can be seen from Figure 14.5. Let us refer to the names described in the previous syntax as semiqualified names. To avoid the problem that a semiqualified ...

Get Access Database Design and Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.