Understanding the Code Window

The Code window is used for Visual Basic programming as well as for viewing and modifying the code of existing Visual Basic procedures. Each VBA module can be opened in a separate Code window.

There are several ways of activating the Code window: From the Project Explorer window, choose the appropriate module and then click the View Code button From the VBE menu, choose View | Code ■ From the keyboard, press F7

At the top of the Code window there are two drop-down list boxes that allow you to move quickly within the Visual Basic code. In the Object box on the left side of the Code window you can select the object whose code you want to view.

Introduction to Access 2003 VBA Programming

Figure 2-4: The Object drop-down box lists objects that are available in the module currently selected in the Project Explorer window.

The box on the right side of the Code window lets you select a procedure to view. When you open this box, the names of all procedures located in a module are listed alphabetically. If you select a procedure in the Procedure box, the cursor will jump to the first line of that procedure.

Figure 2-5: The Procedure drop-down box lists events the object selected in the Object drop-down box can respond to. If the selected module contains events written for the indicated object, the names of these events appear in bold type.

Figure 2-5: The Procedure drop-down box lists events the object selected in the Object drop-down box can respond to. If the selected module contains events written for the indicated object, the names of these events appear in bold type.

By dragging the split bar down to a selected position in the Code window or choosing Window | Split, you can divide the Code window into two panes, as shown in Figure 2-6.

Figure 2-6: By splitting the Code window you can view different sections of a long procedure or a different procedure in each window pane.

Figure 2-6: By splitting the Code window you can view different sections of a long procedure or a different procedure in each window pane.

Part I

Setting up the Code window for the two-pane display is useful for copying, cutting, and pasting sections of code between procedures in the same module. To return to a one-window display, drag the split line all the way to the top of the Code window or choose Window | Split again.

Two icons are at the bottom of the Code window. The Procedure View icon displays only one procedure at a time in the Code window. To select another procedure, use the Procedure drop-down box. The Module View icon displays all the procedures in the selected module. Use the vertical scroll bar in the Code window to scroll through the module's code. The Margin Indicator bar is used by the Visual Basic Editor to display helpful indicators during editing and debugging.

0 0

Post a comment