Chapter 7: Understanding theVisual Basic Editor


In Chapters 5 and 6, we took a brief tour of the VBA environment as well as the structure behind the VBA language. In this chapter, as well as subsequent ones, we are going to drill down to greater levels of detail.

We’ll start here by revisiting the VBA Editor and the menus and toolbars that you will use with it. We’ll look at the different parts of the editor and examine the available options. You will also learn how to use some of the help features available should you need them.

Opening the VBA Editor

A good place to start learning about the editor is to understand the different ways you can access it. You already saw a couple of ways in Chapters 5 and 6, but they are worth reviewing here.

From Microsoft Access, you can access the editor in any of the following ways:

  • Select Tools | Macro | Visual Basic Editor.

  • As you may have noticed from looking at the menu, you can also use ALT - F11.

  • You can create or edit a module from the Modules category of the Database window.

  • You can create an event property from a form or report. You saw how to do this when we looked at forms and events in Chapter 3.

No matter what technique you use to get to the VBA Editor, you should see something like Figure 7-1 when you open it. The main window, occupying most of the editor, is the Code window where you do the actual coding. As you will see in subsequent chapters, the code will vary depending on the object you are looking at.

click to expand
Figure 7-1: The VBA Editor

The Project Explorer window, the window on the upper left side of Figure 7-1, contains not just the list, but the hierarchy of code objects for the project. The Properties window, on the lower left side in Figure 7-1, contains a list of properties associated with an object, such as a form or report, and what their current settings are.

We will look at the interaction of the Properties and Project windows in a bit. However, I want to mention three windows that you will use for testing and debugging: the Immediate window, the Watch window, and the Locals window. These are discussed in greater detail when we look at testing and debugging in Chapter 10.

Each of these windows can be opened, closed, moved, or resized like any other window in the Windows environment. You can also use the View command to assist in this process. As an example, you can close the Properties window by clicking the X in the upper-right corner. To reopen it, select View | Properties Window, or press F4.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net