As a program, Access is built to provide database developers with a lot of flexibility. Part of this flexibility is having different types of objects that carry out quite specific functions. For instance, tables contain your structured data, queries allow you to work with that data, forms present your data and help you to automate database navigation and functions, and reports gather your data for printing.All of the information stored in your tables and manipulated in your queries is contained in fields. All of the information on a form or report is contained in controls. Every item on a form or report is, then, a control. Controls are articles on a form or report that display data, perform actions, or enhance the object in question.
Forms and Reports usually draw information from Tables or Queries. Forms and Reports use graphical objects called controls to link the object back to the underlying table or query. Three important controls are text boxes , frames , and labels. Text boxes display names and numbers stored in your underlying table or query. Frames show pictures and graphs. Labels display text as titles or other markers that describe data, but are not linked to information in the underlying table or query. Other kinds of controls, like lines and rectangles, visually organize the information and group data on-screen. There are three types of basic controls in Access: unbound, bound, and calculated.Note: Access's on-line help has more detailed information on building expressions.
- Unbound: An unbound control allows you to display information that is not stored in the database-- the title of the form or a descriptive label. This kind of control does not have a data source. You use unbound controls to enhance the presentation and clarity of your form by adding titles or descriptive labels, lines, and pictures.
- Bound: A bound control is always linked to information stored in the form's underlying table or query. A text box is always a bound control. To display a person's name in a Mailing List table, the text box would get it from the Name field because you have bound it to that field. You can also use a bound control to display a picture if it is stored in the underlying table.
- Calculated: Calculated controls are a subset of bound controls, but they do not present information as it appears in a table or query. Instead, they operate on data taken from the table or query by using an expression - a combination of operators such as (+, -, and =), control names, field names, and constant values. For example, the following expression would combine a table's FirstName and LastName fields to present them together:
=FirstName + ì î & LastName
The Toolbox is a special kind of toolbar containing buttons that allow you to select the type of control that best suits your needs. Since the same toolbox is used for designing both forms and reports, you may not find all tools useful for all forms.
The toolbox should be visible when you enter the form's Design View . If it is not visible, you can turn it on by selecting Toolbox from the View menu or by selecting the Toolbox icon on the toolbar. The toolbox controls belong to five major categories: text display and entry, presentation of yes/no options, list boxes, graphics and subforms, and layout enhancement tools.
Text boxes and labels are the default tools for looking at information in an Access form or report. Text boxes display the information entered in a field or calculated on the form; labels are captions or descriptive text. You can use labels to create titles and headings. All labels are unbound controls, but they can be attached to other controls. Every text box you create on your form will automatically have an attached label.
The toolbox contains four different kinds of controls for displaying Yes/No values. Check boxes and optionbuttons (also called radio buttons) when turned on or selected indicate a Yes value. A check box contains a check mark when turned on, while an option button has a dot when selected. Toggle buttons indicate a choice between two values. You can change the face of a toggle button to display your own text. An option group shows which option was selected from several alternatives. Option groups frame a set of either check boxes or option buttons .
Note: only one option in the field can be selected for each record.
Access's toolbox contains two varieties of drop-down boxes: a List box and a Combo box. These controls display a series of values from which you can select. They are most useful when entering data. You can take the values for listing in the boxes from existing values in a table or query or from a list you specify using the control's properties. The most effective way to take values from an existing table is to create a query that extracts all the unique values from a table and sorts them.
Forms can be enhanced by including different kinds of graphics objects, or by including other forms inside of the main form. The Graph tool allows you to create a graph in Microsoft Graph and place it on your form. The Subform/Subreport tool lets you insert a pre-existing form into your current form. The bound and unbound object frames allow you to insert onto your form pictures or other OLE objects.
You can improve the appearance of your forms by including lines, boxes, or page breaks. The line and box tools are designated sections of your form that you want to separate visually from other sections. Page breaks allow you to control how much information goes on one page of each form.
Access has easy drag and drop movement of controls in forms and reports. You select a control by clicking on it. You can also select several adjacent controls by "lassoing" them. To lasso, you need to click in an open space on the form, then drag the pointer through all of the controls that you want to select. Make sure that you start lassoing from a point on the form that will allow you to drag through all of the desired controls without intersecting any others. To select controls that are not adjacent, you begin by clicking on the first control, then select subsequent controls by clicking on them while holding down the <Shift> key. Once selected, you can move a control and its attached label anywhere in the form by dragging it to a new location.If you place the cursor on a control's border, you will see one of three options. An open hand means you can move both the control and its attached label. A hand pointing with the index finger means that you can move either the selected control or label, but not both. A double-headed arrow means you can re-size the control. You then move or re-size by holding down the left mouse button and dragging the control to its new location or size.
In Access, properties determine the characteristics of fields, controls, tables, queries, forms, and reports. Every control on a form has properties. Control properties determine the structure and appearance of the control and the characteristics of the data it contains. For instance, using a control's properties, you could set properties that would format all displayed values as currency and in bold type. To modify a control's properties by changing its property sheet, open the property sheet by:
- Double clicking on the control (unless you're using subforms/subreports or unbound object frames).
- Selecting the control by clicking on it. Now either choose Properties from the View menu, or click the Properties button on the toolbar.
- Right-clicking on the control and selecting Properties from the drop-down menu.
A bound control in a form inherits the same property settings that went with the field in the underlying table or query. These settings include the Format, InputMask, and DecimalPlaces properties. If you set the input mask for a telephone number to be !(000)000-0000, then your form would automatically include the parentheses and dash. If you create a calculated control on the form, then it does not inherit any properties from the underlying table or query.
Changing a control's property setting does not affect the property setting for the underlying field. You can set the appearance to be different in a form, but creating a difference usually leads to a cluttered look. Most of the time, for a uniform appearance, it is better to set the Format, InputMask, and DecimalPlaces properties in the underlying table or query. The exception is calculated field properties, which you will want to set to ensure the appearance of your data in the form is as you desire.You customize controls by changing their properties on the property sheet. Access gives you several property categories. All Properties shows all of the control's properties. Data Properties deal with the characteristics of data displayed in the control, like the default data value, format, or number of decimal places. Event Properties specify a macro or module to be executed when an event occurs such as pressing certain keys, clicking or double-clicking the control, or changing data. Layout Properties define appearances like height, width, color, if the control can shrink and grow with the data, and font characteristics. Other Properties show the control's name and the description that appears on the status bar. Note: You select a property by clicking on that option in the property sheet. If you click on the property and an arrow appears, you can click the arrow to display a list of settings. Otherwise, type an entry in the box.
If you want several controls to have the same properties, such as height, width, or color, you can save time by changing the controls as a group rather than individually. To change the property of any control, display the property of any control. Then, select the controls you want to change by holding down the <SHIFT> key and clicking on each one. Change the desired properties in the control sheet.
Once you have created a form or report, you need to remember a few basics about working with controls in Access. First, for the best way to create and position controls on your form, use both the Toolbox and the Form Design Toolbar . The Toolbox, the Field List for the underlying table or query, and the Properties box can be displayed for easy access. You can turn all of these options on by selecting the appropriate buttons from the Form Design toolbar or from the View menu.
The easiest way to create a new control is by selecting the type of control you want in the Toolbox, and then clicking and dragging in the form to create an unbound control. You can then bind the control to a field in the underlying table or query by filling in the Control Source property with the appropriate field name. The best way to create a new control is to combine these two actions into one. When the both the Field List and the Toolbox are displayed, you can select the control type that you want to add in the Toolbox and drag the field you want bound from the Field List to the form's design window.
Access comes with tools that make it easy to get all the controls to their desired location. To align controls use the Snap To Grid command in the Format menu. When this command is turned on, Access automatically aligns controls to the grid. When you have selected multiple controls, you can make the alignments match up. Under the Format menu, select whether you want to align controls with each other or with the grid underneath the form.
- Select the controls you want to align.
- From the Format menu, choose Align, and then choose To Grid . Access will then align the upper left hand corner of each control to the grid.
Note: When you are aligning controls relative to each other, select only controls in the same row or column.
- Select the controls you want to align.
- From the Format menu, choose Align, and then Left, Right, Top, or Bottom depending on which edge you want to align. Left aligns the edges of the controls with the edge of the leftmost control. Right, Top, and Bottom do the same with the edge of the right, top, and bottom-most control.
Older versions of Access had one huge annoyance when it came to form design: you could not change one type of control into another without deleting the control and replacing it with a different type. The designers finally got around to remedying this problem in this version. When you want to change a control's type on the fly, right-click on the desired control and choose Change To from the shortcut menu. This allows you to ìmorphî a text box into a combo box.