Access VBA Macro Programming

(Joao Candeias) #1

CHAPTER


14


The Access


Object Models


T


he Access object models are at the heart of using VBA in Access. They distinguish
programming in Access from programming in other VBA applications by providing
additional commands to manipulate tables, queries, forms, and reports and by
providing all the functionality that the user would normally obtain from the menu structure
of Access. For example, the object model in Microsoft Excel contains commands and objects
specifically relating to workbooks and worksheets, giving you the means to manipulate ranges
and cells. In Access, several object models are used and the whole application is oriented
toward a structure of tables, queries, forms, and reports.
The object model is written around this structure. Access is effectively a three-tier application:
the client services tier, the object model, and the data services layer. The usual Access interface
that you view is the client services tier and is the layer that normally communicates with the
user.
Underneath this sits the various object models. The important ones are Access, DAO (Data
Access Objects), and ADO (ActiveX Data Objects). Each time you do something in your
database, you are issuing commands through one of these object models. For example, if you
create a new query, the underlying code uses theQueryDefscollection and theQueryDef
object in the DAO object model to hold the details of your query.
Similarly, you can use theCurrentDbobject to obtain the file name (and path) of the
database:


MsgBox CurrentDb.Name


TheCurrentDbobject is part of the Access object.

175

Free download pdf