1 ACCESS LESSON 4 – CREATING AND MODIFYING FORMS Creating a Form A form is a db object that displays data from one or more tables or queries (record source) in a format that is similar in appearance to a paper form. Most experts recommend using forms to update databases b/c forms provide more control over the way data is displayed, updated, and entered. Forms are also easier to work with than working in a table datasheet. Access includes tools that you can use to create different kinds of forms. Different options for creating forms are located in the Forms group on the Create tab. The Form tool creates a simple form that includes all the fields in the selected table or query, uses a simple format, and includes a title with the same name as the record source. See Figure 4-1 (p. 86). When fields appear in a form, they appear in controls. You can click the buttons on the record navigation bar at the bottom of the Form window to navigate the records in the record source and display them in the form. When you use a tool to create a form, the form appears in Layout view. In Layout view, you can view the controls in the form and data from the record source at the same time. The Split Form tool creates a form using all the fields in the selected table or query and splits the window into two panes (see Figure 4-2, p. 87). The form is in the top pane and the bottom pane contains a datasheet that contains the form data. The two views are synchronized—when you select a field in the top pane, it is also selected in the bottom pane. The Multiple Items tool creates a form that lists all the fields in a datasheet format, but using a style that is similar to the form created by the Form tool. Step-by-Step 4.1 (p. 87) When you need to create a simple form quickly, use the Form Wizard. The Form Wizard provides four form layouts from which to choose. The Columnar layout displays fields in a stacked column format, with labels to the left of their controls. The Tabular layout displays fields with the labels at the top of a column that contains the field values. The Datasheet layout displays fields in a datasheet format. The Justified layout displays fields across the screen in the order in which they occur. A form’s style, also called AutoFormat, formats the form and its controls using a predefined color, font, and design scheme. You can customize the form with tools and features in Access. Step-by-Step 4.2 (p. 88) Navigating a Form When you create a form using the Form Wizard, the form opens in Form view. When a form is displayed in Form view, you will see each record source in a form. Form view includes a record navigation bar at the bottom of the Form view window (the same buttons with the same functions as the record navigation bar used to navigate records in a table or query datasheet). 2 Step-by-Step 4.3 (p. 89) Using a Form to Find and Replace Data The Find command is available when you are using a table or query datasheet, form, or report. Click the Find button in the Find group on the Home tab and the Find and Replace dialog box opens (see Figure 45, p. 90) If you select part of a field value in the form (one or more characters or a single word) before clicking the Find button, the selected text appears in the Find What list box automatically. When the Find What list box is empty, type the value you want to find in the text box. When a field is selected in the form, its name appears in the Look In list box when you open the Find and Replace dialog box. If you want to search the entire table for a matching field value, click the Look In arrow, and then click the form name. You can use the options in the Match menu to search any part of the field, the whole field, or the start of the field. See bulleted list on p. 90. The Search feature lets you search the entire form, or up and down from the location of the insertion point. The two check boxes—Match Case and Search Fields as Formatted—let you search for a value that has the same case as the entry in the Find What list box and search for formatted values. To start searching the form for matching records, click Find Next. Click the Replace tab to see additional options for finding text and replacing it with different text. Note the Replace All box. Step-by-Step 4.4 (p. 91) Be careful when replacing text, because you might accidentally replace text that you didn’t intend to change. Using a Form to Update Data You can also use a form to update the record source, add new records, or delete existing records. To change a field value, select it and type the new value. To add a new record, click the New button in the Records group on the Home tab to open a blank form, into which you can type the field values for the new record. When you are finished adding the new record, tab to a new record or close the form. Step-by-Step 4.5 (p. 92) The newly added record is not at the end of the datasheet table because the new record appears in order based on the values in the primary key field. Using a Form to Delete Data Access provides two important options when using a form to delete a field value or record. When you click the Delete button in the Records group on the Home tab, you’ll delete the selected field value. If you click the arrow on the Delete button, and then click Delete Record, you’ll delete the record that is currently displayed in the form. You can use the Undo button to restore a deleted field value, but deleting a record permanently deletes it from the record source. Step-by-Step 4.6 (p. 94) 3 Creating and Modifying a Form in Layout View To create a blank form, click the Create tab, and then click the Blank Form button in the Forms group. A blank form opens in Layout view, and the Field List pane opens on the right side of the screen. The Field List pane contains the tables in the database and displays the fields they contain. When you doubleclick a field in the Field List, Access adds the field to the form. The fields are added to a control layout. a control layout is a “container” that groups together the controls in a form so that you can change them as a group. You can change the way the controls are arranged by changing the control layout, or you can remove controls from the layout to work with individual controls. The first task creating a form from scratch is to create the form in Layout view, and then to use the Field List to add fields to the form. Step-by-Step 4.7 (p. 95) Adding a Title to a Form and Changing its Format When you create a form, it contains one section called the Detail section. The Detail section contains controls that display one record at a time from the record source. You can add two additional sections to the form: Form Header section displays info at the top of each form; Form Footer section displays info at the bottom of each form. When you add a control to one of these additional sections, they are added to the form as a pair. The Controls group on the Format tab in Layout view includes buttons that add different types of controls to a form. There are two types of controls: 1. bound control is connected to a field in the record source and is used to display, enter, and update data. 2. unbound control is not connected to a record source and is used to display info, lines, rectangles, and pictures. To add a title to a form which adds an unbound control to the form, click the Title button in the Controls group on the Format tab. Access will add the Form Header and Form Footer sections to the form and add a title control to the Form Header section. The default title is the form’s name. You can edit the title—just click and edit text as you normally would. You can also change the default font size, color, and style of the title text using the button in the Font group on the Format tab. Step-by-Step 4.8 (p. 98) Resizing a Control in a Form When you resize controls in a control layout in Layout view, reducing the width of one control reduces the widths of all other controls in the control layout at the same time. You can resize a control by dragging its edge to a new location. You can also resize a control precisely by watching the lower-left corner of the status bar to see the width of the control in characters as you drag it. Step-by-Step 4.9 (p. 99) Moving a Control in a Form When controls are grouped in a control layout, moving one control moves all the controls in the group. When you need to move one or more controls in a form, you’ll need to remove them from the control layout first. To select one control, you click it. To select a group of controls, click the first control, press and hold down the Shift key, click the other controls, and then release the Shift key. Step-by-Step 4.10 (p. 100) 4 Adding an Unbound Control to a Form in Design View In Design view for a form, you see the controls that you added to the form on a grid, see Figure 4-18 (p. 102). Here, the controls do not display data from the record source. You must be in Design view to add controls such as lines, rectangles, and labels to a form. You add controls to the form by clicking the button for the desired control I the Controls group o the Design tab, and then clicking to position the control in the form. In Design view, you see the Form Header, Detail, and Form Footer sections in the form. Each section contains a section bar at the top that you can click and select. You adjust the size of the section by clicking the bottom edge of the section and dragging it up or down to change its height. When you don’t’ see a grid below a section, the section height is set to zero. Step-by-Step 4.11 (p. 103) Previewing and Printing a Form To preview a form, click the Office Button, point to Print, and then click Print Preview. Each record source appears in a miniature version of the form, one after the other on the page. To print all records in form from Print Preview, click the Print button in the Print group on the Print Preview tab. To print the form with the current record displayed, you must be in Form view and navigate to the desired record. Click the Office Button, point to Print, and then click Print. The Print dialog box opens. Click the Selected Records option button, and then click OK. Step-by-Step 4.12 (p. 105)