In this chapter, you’ll learn how to create, edit, and test Microsoft Visual Basic code in your Microsoft Office Access 2007 applications. The chapter covers the following major topics:
The Visual Basic Editor (VBE) and its debugging tools
Variables and constants and how to declare them
The primary object models defined in access-the Access model, the Data Access Objects (DAO) model, and the ActiveX Data Objects (ADO) model.
You’ll need to understand these models to be able to manipulate objects such as forms, form controls, and recordsets in your code.
Visual Basic procedural statements
Function and Sub statements
Property Get, Property Let, and Property Set (for use in class modules) statements
Flow-control statements, including Call, Do, For, If, and Select Case
DoCmd and RunCommand statements
On Error statements
A walk-through of some example code you’ll find in the sample databases
If you’re new to Visual Basic, you might want to read through the chapter from beginning to end, but keep in mind that the large section in the middle of the chapter on procedural statements is designed to be used primarily as a reference. If you’re already familiar with Visual Basic, you might want to review the sections on the Visual Basic Editor and the object models, and then use the rest of the chapter as reference material.
You can find many of the code examples from this chapter in the modExamples module in the Contacts.accdb and Housing.accdb sample databases on the companion CD.