Access 2007 Forms Tips & Ideas
Wednesday, June 25th, 2008Try the Form Tool First
Go to the database window, click a table within the Navigation Pane, click the Create tab, and within the Forms Group, click Form to display the new form. If you don’t like the result, don’t bother to save the form. You have lost all of 30 seconds and can start again with the Form Wizard.
Anatomy of a Form
A form is divided into one or more sections. Virtually every form has a detail section to display or enter the records in the underlying table. You can, however, increase the effectiveness or visual appeal of a form by adding a header and/or footer. Either section may contain descriptive information about the form, such as a title, instructions for using the form, or a graphic or logo.
Floating Toolbars
A toolbar is typically docked (fixed) along the edge of the application window, but it can be displayed as a floating toolbar within the application windows. To move a docked toolbar, drag the toolbar background (or the toolbar’s move handle). To move a floating toolbar, drag its title bar. To size a floating toolbar, drag any border in the direction you want to go. And finally, you can double-click the background of any floating toolbar to dock it.
Snap to Grid versus Free Form Movement of Controls
Some form and report developers prefer having the freedom to have move and position controls with pinpoint precision that they control. If you are working in free form, after you have selected a control you can move it a pixel at a time by using any of your four arrow keys.
Sizing or Moving a Control and its Labels
A bound and/or unbound control is created with an attached label. Select (click) the control, and the control has sizing handles and a move handle, but the label has only a move handle. Select the label (instead of the control), and the opposite occurs; the control has only a move handle, but the label will have both sizing handles and a move handle. To move a control and its label, click and drag the border of either object. To move either the control or its label, click and drag the move handle (a tiny square in the upper left corner) of the appropriate object.
Use the Property Sheet
You can change the appearance or behavior of a control in two ways by changing the actual control on the form itself or by changing the underlying property sheet. Anything you do to the control automatically changes the associated property, and conversely, any change to the property sheet is reflected in the appearance or behavior of the control. In general, you can obtain greater precision through the property sheet, but we find ourselves continually switching back and forth between the two techniques. Every object in an Access database has its own property sheet.
Align the Controls
To align controls in a straight line (horizontally or vertically), press and hold the Shift key and click the labels of the controls to be aligned.
Troubleshooting Focus Issues
A common error occurs when entering new or adjusting existing records. This is because you probably attempted to move focus to another record or perform another action (such as change views) and a required field in the new record (set during table design) was not completed.
Error Messages - #NAME? Or #ERROR?
The most common reason for either message is that the control source references a field that no longer exists, or a field whose name is misspelled. Go to the Design view, right-click the control, click Properties, then click the All tab. Look at the Control Source property and check the spelling of every field. Be sure there are brackets around each field in a calculated control. For example, =[QualityPoints]/[Credits]. Don’t forget that the spelling is case sensitive and there should be no spaces in variable names!
The Lookup Wizard and Relational Databases
The simplest way to use the Lookup Wizard is to type the potential values directly into the associated field. It’s more powerful, however, to instruct the wizard to look up the values in a table, which in turn necessitates the creation of that table, in effect creating a relational database. Indeed, the true power of Access comes from databases with multiple tables.
Bound Controls and Inheritance
A bound control inherits its properties from the associated field in the underlying table. A check box, for example, appears automatically for any field that was defined as a Yes/No field. In similar fashion, a drop-down list appears for any field that was defined through the Lookup Wizard. All of the other properties of the control are also inherited from the underlying table.
Windows Themes and Rounded Command Buttons
It’s a subtle difference, but we prefer the sleeker look of rounded command buttons on our forms, as opposed to the rectangular buttons that are created by default. Click the Microsoft Office Home Button, click Access Options, and click Current Database. Check the box to Use Windows-themed Controls on Forms, click OK, then close the Window. Save the form you are working on, and then reopen it. You should see rounded buttons.
Multiple Controls and Properties
Press and hold Shift as you click one control after another to select multiple controls. To view or change the properties for the selected controls, right-click any one of the selected controls, then click Properties to display a Property Sheet. If the value of a property is the same for all selected controls, that value will appear in the property sheet; otherwise the box for that property will be blank. Changing a property when multiple controls are selected changes the property for all selected controls.
The Tab Stop Property
The Tab key provides a shortcut in the finished form to move from one field to the next. Calculated controls, such as GPA, are not entered explicitly, however, and can be bypassed by setting the Tab Stop property to No. AutoNumber fields can be bypassed in similar fashion. Note, too, that the order in which fields are selected corresponds to the sequence in which the controls were entered onto the form, and need not correspond to the physical appearance of the actual form.
To restore a left-to-right, top-to-bottom sequence, click the Arrange tab, in the Control Layout Group, click Tab Order to display the Tab Order dialog box.