Online Book Reader

Home Category

Access Cookbook - Ken Getz [6]

By Root 1855 0

Drag the mouse through the ruler (either horizontal or vertical). Access will select each of the controls in the path you dragged over. If partially selected controls don't become part of the selection and you'd like them to, open Tools→ Options → Forms/Reports and look at the Selection Behavior option. It should be set to Partially Enclosed.

Multiple controls

If you need to select all but a few controls, select them all and then remove the ones you don't want. To do this, choose the Edit → Select All menu item. Then Shift+Click on the controls you don't want included.

Make sure the properties window is visible. If it's not, use View → Properties (or the corresponding toolbar button).

If you've selected a single control, all the properties will be available in the properties window. If you've selected multiple controls, only the intersection of the selected controls' properties will be available in the properties window. That is, only the properties all the selected controls have in common will appear in the list. As shown in Figure P-1. Select a property group and then assign the value you need to the selected property. Repeat this process for any other properties you'd like to set for the same control or group of controls.

Figure P-1. The properties window shows the intersection of available properties when you've selected multiple controls

TIP

For more information, browse the various topics under properties; setting in Access online help.

How Do I Create a New Module?


VBA code is stored in containers called modules, each consisting of a single declarations section, perhaps followed by one or more procedures. There are two kinds of modules in Access: global modules and class modules. Global modules are the ones you see in the database window, once you choose the Modules tab. Class modules are stored with either a form or a report and never appear in the database window. (Actually, you can also create standalone class modules, which do appear in the database window. The use of these types of modules, which allow you to define the behavior for your own objects, is beyond the scope of this book.) There are various reasons to use one or the other of the two module types, but the most important consideration is the availability of procedures and variables. Procedures that exist in global modules can, for the most part, be called from any place in Access. Procedures that exist in a class module generally can be called only from that particular form or report and never from anywhere else in Access.

You'll never have to create a form or report module, because Access creates those kinds of modules for you when you create the objects to which they're attached. To create a global module, follow these steps:

From the Database Explorer, click on the Modules tab to select the collection of modules, then click on the New button (or just choose the Insert ‡ Module menu item).

When Access first creates the module, it places you in the declarations section. A discussion of all the possible items in the declarations section is beyond the scope of this Preface, but you should always take one particular step at this point: if you don't see Option Explicit at the top of the module, insert it yourself. Then use the Tools → Options menu from within the VBA editor to turn on the Require Variable Declaration option (see Figure P-2). With this option turned on, all new modules you create will automatically include the Option Explicit statement. If you don't insert this statement and Access encounters a reference to an unknown variable, Access will create the variable for you. With the Option Explicit statement, Access forces you to declare each variable before you use it.

Although this may seem like an unnecessary burden for a beginner, it's not. It's an incredible time saver for all levels of users. With the Option Explicit statement in place, you can let Access check your code for misspellings. Without it, if you misspell a variable name, Access will just create a new one with the new name and go about its business.

Return Main Page Previous Page Next Page

®Online Book Reader