Share this Page URL

Chapter 5. Using Visual Basic to Automat... > Using an Object Model - Pg. 179

Using Visual Basic to Automate Your Database 179 Using an Object Model In the final few sections of this chapter, we'll review in more detail the makeup of an object model and look at some code examples, including examples that use the DAO and ADO object models to work with data in a database. We'll also write a procedure that uses the Microsoft Outlook object model from Access to send an e-mail message with an attachment. We'll use this procedure and others in later chapters as we add to the tasks performed by the HelloWorld database in tracking the workflow for our marketing campaigns. Elements of an Object Model Object models provide the means to work with applications, data access, shared components, and other technologies in your code. In the Access object model, a database is considered an object, as is each form, report, text box, button, and so on. An application's object model is organized hierarchically, often with an object named Application at the top of the model. Other objects are considered children of the Application object and can be part of a parent/child relationship with other objects as well. The Access object model is designed mainly to work with the forms, reports, controls, and other objects in Access. To work with the data a database stores, you use the DAO or ADO object model. Properties, Methods, and Events You've worked already with three main elements of an object: properties, methods, and events. (Not all objects have all three elements.) Properties are characteristics of an object, such as a form's background color, height, and width; the last time a table was updated (we used the LastUpdated property in the Import procedure earlier); whether a list box is visible (the Visible property would be