logo

Microsoft Office Access 2007 P2


14 Chapter 1 Creating and Using a Form 7. If you want to use the form right away, leave the Open the Form to View or Enter Information option activated. Alternatively, click Modify the Form’s Design to open the form in Design view (see “Creating a Form in Design View,” later in this chapter). 1 8. Click Finish to complete the form. This is the end of the Form Wizard. You can create a sophisticated and professional data entry form in a fraction of the time needed to create the form from scratch. The wizard isn’t as fast as the Form, Split Form, and Multiple Items commands, but it does allow a bit more flexibility in the customization. Navigating a Form Navigation in a form refers not just to the fields that appear on the form but also to the records within the form. When you’re working on a form, you can navigate the form using several methods. The first is to use the Enter key. The Enter key accepts the data that the user entered into the field and moves the focus to the next field. The Tab key performs the same action, but the user doesn’t need to enter any data. If shortcut keys are associated with buttons on the form, the user can hold down the Alt key and press the corresponding underlined letter. For moving between records, the easiest technique is to use the record navigation buttons that appear at the bottom of the form. ➔ To learn how to specify shortcut keys for form controls, see“Using Labels to Create Keyboard Shortcuts for Controls,”p. 42. (Chapter 2) Otherwise, to navigate fields and records in a form, you can use the keys outlined in Table 1.1. Table 1.1 Keys to Use When Navigating Fields and Records in a Form Key Description Tab or right arrow Moves to the next field to the right; from the last field, moves down to the first field in the next record. Shift+Tab or left arrow Moves to the previous field to the left; from the last field, moves up to the first field in the previous record. Home Moves to the first field. End Moves to the last field. Page Down Moves to the same field in the next record. Page Up Moves to the same field in the previous record. Ctrl+Home Moves to the first field of the first record. Ctrl+End Moves to the last field of the last record. Creating a Form in Design View 15 Creating a Form in Design View Although the Form Wizard is a step up from the Form, Split Form, and Multiple Items commands in terms of control, the resulting forms still might not satisfy your needs. For 1 example, you might want to build a custom form that mirrors as closely as possible an equivalent paper form. If the Access form resembles the paper form, the person using the form to enter data will feel more comfortable with it and will be less likely to make mis- takes. For maximum form flexibility, you need to use the form design window, which gives you total control over the form, including the positioning of the controls, the formatting of the text, the colors, and much more. Displaying the Design View Access forms have a Design view that you can use for your customization chores. How you display this view depends on whether you’re dealing with an existing form or a new one. To open an existing form in Design view, you have two choices: ■ If the form isn’t open, right-click the form in the Navigation pane and then click Design View. ■ If the form is already open, choose Home, click the lower half of the View split button, and then click Design View. (Alternatively, click the Design View button on the status bar; see Figure 1.8.) To start a new form, you have two choices: ■ Choose Create, Blank Form. Then choose Format, click the lower half of the View split button, and then click Design View. ■ Choose Create, Form Design. When you create a new form, it isn’t associated with a table or query, so you need to set the record source by hand. See “Changing the Record Source,” next. Figure 1.8 shows a new, blank form in Design view. Note that you place the form controls, including the table’s fields and their labels, in the Detail area. Changing the Record Source The fields available to the form depend on the table or query that you’ve defined as the form’s record source. If you’ve created a blank form, you need to specify the record source yourself. For an existing form, you might want to change the record source to a different table or query. Either way, you follow these steps to change the record source while you’re in Design view: 16 Chapter 1 Creating and Using a Form 1. Select the form by clicking the form selector button (pointed out in Figure 1.8). 2. Choose Design, Property Sheet. The Property Sheet pane appears. 1 3. Click the Data tab. 4. Pull down the Record Source list and then click the table or query you want to associ- ate with the form. 5. Choose Design, Property Sheet. The Property Sheet pane disappears. Figure 1.8 Use the Design view to design and customize all aspects of your form. Understanding Form Controls An Access form can contain one of three types of controls: bound, unbound, or calculated. The following sections discuss the differences between these types. Bound Controls (Fields) You use bound controls to display and edit data from the form’s underlying record source. The term bound refers to the fact that the control is tied to a field of a table, query, or SQL SELECT statement. The most common type of bound control is the text box, but many other types of controls can operate as bound controls. A bound control inherits many of its formatting and text properties from the field to which it is bound (for example, Caption, Description, Input Mask, and Default Value). You can Creating a Form in Design View 17 change these properties on the form by using the control’s property sheet, which you dis- play as follows: ■ Click the control (the data control, not the associated label) and then choose Design, 1 Property Sheet (or press Alt+Enter). ■ Right-click the control and then click Properties. See “Adding Fields to the Form,” later in this chapter, to learn how to add a bound control to the form. Unbound Controls An unbound control is used to convey information to the user or to receive from the user input that won’t be stored in the underlying record source. In other words, unbound means that the control isn’t associated with (bound to) any field. Here are some examples of using unbound controls: ■ A label for a text box that describes what the text box represents. ■ Text boxes or drop-down list boxes that can be used to select different scenarios on a what-if form. ■ A line used to separate different sections of the form. ■ A company logo or other graphical effects. When you add a control to a form when the Control Wizard is activated, the control is automatically unbound. ➔ To learn about adding unbound controls and using the Control Wizard, see“Inserting Controls on a Form,”p. 30. (Chapter 2) Calculated Controls Calculated controls use expressions to derive their data. Expressions are combinations of operators, fields, control names, functions, and constants. Although text boxes are the most common form of calculated controls, any control having the Control Source property can be a calculated control. A calculated control can be used to compute sales tax on an order entry form, for example. ➔ To learn how to build calculated controls, see“Using Text Boxes as Calculated Controls,”p. 44. (Chapter 2) Adding Fields to the Form Here are the steps to follow to add a field (that is, a bound control) to your form: 1. Choose Design, Add Existing Fields. Access displays the Field List pane. 2. Double-click the field you want to add to the form. 3. Repeat step 2 until you have added all the fields you need. 18 Chapter 1 Creating and Using a Form When you add a field, Access creates a control for the field as follows (see Figure 1.9): ■ Most text or numeric fields use a text box. 1 ■ If the field is used as the basis of a one-to-many relationship with another table and the current table is the “many” side of that relationship, the field is displayed as a drop- down list that contains the values from the related table. ■ Yes/No fields use a check box. Also, a label control is placed beside each field. The text of the label is the Caption prop- erty for the field to which the control is bound. Labels Fields Figure 1.9 Some fields from the Products table added to the form. Form View Changing the Size of the Form If you find that your form is either too small to hold all the fields or has too much empty space, you can change the size of the form as follows: ■ To adjust the form’s height, move the mouse pointer to the bottom edge of the Detail area. Click and drag the edge of the form down (to make the form bigger) or up (to make the form smaller). ■ To adjust the form’s width, move the mouse pointer to the right edge of the Detail area. Click and drag the edge of the form right (to make the form wider) or left (to make the form thinner). Viewing the Form After you’ve added at least one field, you can display the underlying record source in the form by switching to Form view. You have two choices: Creating a Form in Design View 19 ■ Choose Design and then click the top half of the View split button. ■ In the status bar, click Form View (see Figure 1.9). 1 Figure 1.10 shows the Form view of the design displayed in Figure 1.9. Figure 1.10 The Form view of the form design shown in Figure 1.9. Assigning an AutoFormat in Design View You learn how to change control fonts, colors, borders, and other formatting in Chapter 2, “Working with Form Controls.” For now, you can do some quick formatting by applying one of the 20 predefined form looks, called AutoFormats. Choose the Arrange tab (not, sur- prisingly, the Design tab), click AutoFormat to display the AutoFormat gallery, and then click the look you prefer. ➔ For the specifics of form formatting, see“Formatting Controls,”p. 31. (Chapter 2) For a bit more control, you can use the AutoFormat Wizard: 1. Choose Arrange, AutoFormat, AutoFormat Windows to display the AutoFormat dia- log box. 2. In the Form AutoFormats list, click the AutoFormat you want to use. 3. To control which layout attributes Access applies to the form, click Options to display the Attributes to Apply group and then activate or deactivate the following check boxes: Font, Color, and Border. 4. Click OK. The default layout used by the Form Wizard is always the most recent layout that you selected in NOTE the AutoFormat dialog box. Note, too, that you can customize these AutoFormats to suit your taste. In the AutoFormat dialog box, click the Customize button to display the Customize AutoFormat dialog box that has three options: 20 Chapter 1 Creating and Using a Form ■ Create a New AutoFormat Based on the Form ‘Form’—Choose this option to cre- ate a new AutoFormat template based on the formatting used in the current form. ■ Update AutoFormat with Values from the Form ‘Form’—Choose this option to 1 change the currently selected AutoFormat template based on the formatting used in the current form. ■ Delete AutoFormat—Choose this option to delete the currently selected AutoFormat template. Working with Form Properties Any form object comes with a large number of properties that you can work with. Many of these are obscure and can be safely ignored, but there are a few that you might find useful. To work with the form properties, follow these steps: 1. Select the form by clicking the form selector button, pointed out earlier in Figure 1.8. 2. Choose Design, Property Sheet (or press Alt+Enter) to display the Property Sheet pane. 3. Modify the properties you want to work with. If you’re not sure what a property does, click inside the property and then press F1. Access loads the TIP Help window and displays the Help topic for that property. 4. Click the Close button (X) to activate the new settings. Working with the Form Header and Footer The Detail section of a form is supposed to be a data-only area. That is, it’s supposed to contain only controls that are directly or indirectly related to the form’s underlying record source. What if you want to display a form title or the current date or some other informa- tion not related to the data? Although it’s possible to put such things in the Detail area, a better choice is to take advantage of the following sections: ■ Form Header—This section appears above and separate from the Detail area, so it’s a good choice for the form title, a company logo, or any other items that you want dis- played separately from the form data. Note that when you print the form, the Form Header appears only at the top of the first page. Creating a Form in Design View 21 ■ Form Footer—This section appears below and separate from the Detail area. It’s a good place to add nondata items such as the current date or instructions on how to fill in the form. When you print the form, the Form Header only appears below the Detail section on the last page. 1 To display the Form Header and Form Footer, choose the Arrange tab and then click the Form Header/Footer button in the Show/Hide group. Besides the Form Header and Form Footer, Access also defines separate Page Header and Page Footer sections, both of which appear only when you print the form: ■ Page Header—This section appears at the top of each printed page (except for the first printed page, where it appears below the Form Header). ■ Page Footer—This section appears at the bottom of each printed page. To display the Page Header and Page Footer, choose the Arrange tab and then click the Page Header/Footer button in the Show/Hide group. Figure 1.11 shows a form with the four header and footer sections added. Note that if you need to select a section (to format it, for example), you can do so by using either of the fol- lowing techniques: ■ Click the separator bar above the section you want to work with. ■ Choose Design, Property Sheet and then use the Object list in the Property Sheet pane (pointed out in Figure 1.11) to choose the section you want. Figure 1.12 shows the Form view, which displays the Form Header and Form Footer sections. To change the height of any section, move the mouse pointer to the bottom edge of the section. NOTE Then click and drag up or down to resize the section. 22 Chapter 1 Creating and Using a Form 1 Figure 1.11 A form with the Form Header, Form Footer, Page Header, and Page Footer. Figure 1.12 The Form view shows the Form Header and Form Footer sections. Adding a Logo You can add visual appeal to a form by adding a logo to the form header. This will most often be a company logo, but you might also want to use different logos for different pro- jects, teams, or departments. In previous versions of Access, you could insert a logo using the Image control, but you usually had to spend time resizing the resulting image. Access 2007 comes with a separate Logo command that automatically inserts the image into the Form Header section and adjusts the image’s dimensions to logo size (usually 0.6 inch square). The resulting image is an Auto_Logo object. Creating a Form in Design View 23 Here are the steps to follow to insert a logo: 1. Choose Design, Logo. Access displays the Insert Picture dialog box. 2. Navigate to the folder that contains the image you want to use as a logo. 1 3. Click the image. 4. Click OK. Access resizes the image and inserts it in the Form Header section. Adding a Title Adding a title to your form is usually a good idea so that users have some idea what the form is used for. You can use a Label control to add a title, but Access 2007 comes with a new Title command that automatically inserts an Auto_Title object in the Form Header section. Here are the steps to follow to insert a title: 1. Choose Design, Title (just to the right of the Logo button). Access adds the Auto_Title object to the Form Header. 2. Type your title. (Note that the Auto_Title box expands automatically as you type your text.) 3. Click outside the title. 4. Move the title to the position you want. ➔ For information on moving controls, see“Moving Controls,”p. 34. (Chapter 2) Formatting the Background Most of the formatting options apply to the controls, as you’ll see in Chapter 2. For the form itself, about the only thing you can do is change the look of the background for each section: You can change the background color, or you can display an image as the back- ground, as described in the next two sections. Setting the Background Color To change the background color of a form section, follow these steps: 1. Click the section’s separator bar to select the section. 2. On the Design tab, click the Fill/Back Color palette (see Figure 1.13) so that it drops down. 3. Click the background color you want. 24 Chapter 1 Creating and Using a Form CAUTION When choosing a background, make sure the color doesn’t clash with the color of the field label 1 text. For example, the default label text color is black, so any dark background will cause a problem. Either use a light color for the background or change the color of the label text (as described in Chapter 2). Figure 1.13 Click the Fill/Back Color palette and then click the background color you want. Setting the Background Picture A simple, solid-color background that contrasts well with the form text (for example, a white or light-colored background with black or dark-colored text) is often the safest bet in a business environment. However, you might feel the need to spice up your form a bit with a more interesting background treatment: an image. Access enables you to use either a sin- gle, large image as the background or smaller images that are stretched or tiled to cover the entire form. Follow these steps to set an image as a form’s background: 1. Select the form. 2. Choose Design, Property Sheet to open the Property Sheet pane. 3. Click the Format tab. 4. Click inside the Picture property and then click the ellipsis … button. Access displays the Insert Picture dialog box. 5. Find the file you want to use, click it, and then click OK. Creating a Form Interactively in Layout View 25 6. Use the Picture Size Mode property to choose one of the following settings: • Clip—The image is displayed using its actual dimensions. If the image is larger than the form, the edges of the image are clipped to fit. 1 • Stretch—The image is stretched or shrunk vertically and horizontally so that it fills the entire form. • Zoom—The image is enlarged or reduced until it fills the form either vertically or horizontally; the image’s original proportions are maintained. • Stretch Horizontal—The image is stretched or reduced horizontally so that it fills the entire form width. • Stretch Vertical—The image is stretched or reduced vertically so that it fills the entire form height. 7. Use the Picture Alignment property to specify how you want the image aligned within the form. 8. If you selected either Clip or Zoom as the Picture Size Mode, use the Picture Tiling property to determine whether you want the image repeated (tiled) across the back- ground so that it fills the entire form; select Yes for tiling; select No to display just a single image. 9. Close the property sheet. CAUTION As with the background color, be careful which image you choose for the background. A “busy” background can render label text unreadable. Creating a Form Interactively in Layout View The major problem with creating a form in Design view is that you don’t see data from the form’s record source until you switch to Form view. This means that you often have to switch back and forth to get the layout you prefer and to size the controls properly. Access 2007 helps you reduce much of this design drudgery by offering a new form view called Layout. This hybrid view shows you the data from the record source but also enables you to change many aspects of the form design. To switch to this view from Design view, choose Design, click the lower half of the View split button, and then click Layout View. (You can also click the Layout View button in the status bar.) As you can see in Figure 1.14, the form data appears, but you also have access the Ribbon’s Format and Arrange tabs, which enable you to change the font, add certain controls (such as a logo and title), add fields, apply an AutoFormat, and more. 26 Chapter 1 Creating and Using a Form Figure 1.14 Use Access 2007’s new Layout View to modify 1 the form and see its data at the same time. C A S E S T U DY Protecting the Form and Data from Other Users In a business environment, it’s common to build forms as front ends for other users. A properly designed form gives users easier access to the data and keeps them away from fields they don’t need to see (such as primary key fields and sensi- tive data). As you’ll see in the next few chapters, building good business forms takes a bit of extra work on your part. So if you go to all that trouble, the last thing you want is for the users to either change the form design (on purpose or inad- vertently) or alter the data in some unacceptable way (such as deleting records). Access can help you protect both the form and the underlying data.The property sheet for a form contains a number of properties that enable you to restrict the actions that users can take with your form. You can protect the form design in the following ways: ■ Preventing the form from being resized—In the form property sheet, click the Format tab and choose any Border Style setting other than Sizable (that is, None, Thin, or Dialog). ■ Preventing the form from being maximized or minimized—In the Format tab, go to the Min Max Buttons property and choose None. If you want to prevent the form only from being maximized, choose Min Enabled; if you want to prevent the form only from being minimized, choose Max Enabled. ■ Preventing the form from being moved—In the Format tab, choose No for the Moveable property. ■ Disabling other form views—In the Format tab, choose No for each of the following views you want to disable: Allow Datasheet View, Allow PivotTable View, Allow PivotChart View, and Allow Layout View. You can protect the form data in the following ways: ➔ You can also set up validation rules to ensure data integrity.See“Preventing Errors by Validating Data,”p. 50 (Chapter 3) From Here 27 ■ Preventing the user from editing data—In the form property sheet, display the Data tab and set the Allow Edits property to No. 1 ■ Preventing the user from deleting data—In the Data tab, set the Allow Deletions property to No. ■ Preventing the user from adding records—In the Data tab, set the Allow Additions property to No. ■ Preventing the user from seeing other data—In the Data tab, set the Data Entry property to Yes.This is different from Allow Additions in that when this feature is turned on, the form automatically opens to a new, blank record.The user doesn’t have the capability to view existing records. Note that the users cannot see existing records or add new data (in other words, they won’t be able to do anything with the form data) if Allow Additions is set to No and Data Entry is set to Yes. ■ Making form data read-only—In the Data tab, set the Recordset Type property to Snapshot.This is the same as setting the Allow Edits, Allow Deletions, and Allow Additions properties to No. ■ Preventing multiple users from editing the same record simultaneously—In the Data tab, set the Record Locks property to Edited Record. (If you prefer that other users can’t edit any record while one user has the form open, set Record Locks to All Records, instead.) From Here ➔ Unbound controls are the subject of Chapter 2,“Working with Form Controls.”See p. 29. (Chapter 2) ➔ For the specifics of form formatting, see“Formatting Controls,”p. 31. (Chapter 2) ➔ To learn how to specify shortcut keys for form controls, see“Using Labels to Create Keyboard Shortcuts for Controls,”p. 42. (Chapter 2) ➔ To learn how to build calculated controls, see“Using Text Boxes as Calculated Controls,”p. 44. (Chapter 2) ➔ To learn how to set up validation rules to ensure data integrity, see“Preventing Errors by Validating Data,”p. 50. (Chapter 3) ➔ The Form Wizard even lets you select fields from multiple tables; see“Creating a Form and Subform with the Form Wizard,”p. 96. (Chapter 5) ➔ To learn how to build a PivotChart form, see“Creating a PivotChart Form,”p. 108. (Chapter 5) ➔ To learn how to build a modal dialog box, see“Creating a Form Pop-Up Box or Dialog Box,”p. 103. (Chapter 5) ➔ For the specifics of working with the PivotTable view fields, see“Creating PivotTable Queries,”p. 311. (Chapter 14) This page intentionally left blank Working with Form Controls If you want a form laid out in a certain way that either mimics the arrangement of a paper form or gives the form a design that you think will make sense for the users, the techniques you’ve seen so 2 far haven’t given you the tools to do the job. For example, pre-fab form layouts and the Form IN THIS CHAPTER Wizard, although easy and fast, arrange form con- Manipulating Form Controls . . . . . . . . . . . . . . 29 trols in only a few basic designs. Using the Design Adding Labels to the Form . . . . . . . . . . . . . . . 41 view is better because you can at least click and drag the table fields and drop them anywhere you Adding Text Boxes to the Form . . . . . . . . . . . . 43 want on the form. However, if you’ve tried this, Case Study: Creating a Mortgage you’ve certainly noticed that the results are seldom Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 perfect. The reason is that you still need to “fine- tune” the controls by moving them, sizing them, From Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 formatting them, and so on. These fine-tuning techniques are the subject of this chapter. You learn not only how to insert and manipulate form controls, but also how to get the most out of the two most common control types: labels and text boxes. Manipulating Form Controls You saw in Chapter 1, “Creating and Using a Form,” that when you add a field to a form, Access mostly uses text boxes, combo boxes, and check boxes to enable the user to insert and edit field data. Whether you stick with the controls that Access suggests, or you branch out to use other types of controls on your forms, your form-building duties will be much quicker and of higher quality if you get comfortable manipulating the controls to get them exactly the way you want them. To that end, in the following sections you learn quite a few useful techniques that you can apply to any control. 30 Chapter 2 Working with Form Controls Inserting Controls on a Form As you learned in Chapter 1, you add bound controls to the form by double-clicking fields in the Field List pane. For unbound controls (or controls that you want to bind to a field later), you need to use the Design tab’s Controls group, which contains buttons for all the controls you can add to a form. Some of these controls—specifically, Option Group, Combo Box, List Box, Command Button, and Subform—also come with their own Control Wizard that takes you step by step through the process of creating and setting up the control. (For example, the Combo Box and List Box controls have wizards that help you define, among 2 other things, the items that appear in each list.) Here are the basic steps to follow to add any control to the form: 1. In the Design tab, use the Controls group to click the button you want to use. 2. If the control type has an associated wizard, click the Use Control Wizards button (pointed out later, in Figure 2.1) to toggle the wizard on or off, as preferred. 3. Move the mouse pointer into the form and position it where you want the top-left corner of the control to appear. 4. Click and drag the mouse pointer. Access displays a dashed border indicating the outline of the control. 5. When the control is the size and shape you want, release the mouse button. Access creates the control and gives it a default name (such as CheckBoxn, where n signifies that this is the nth check box you’ve created on this form). 6. If the control has a wizard and you activated the Use Control Wizards button, the first wizard dialog box appears. Follow the wizard’s steps. (You learn the control wizards later in this chapter when I take you through the specifics of each control.) Note that sometimes Access also includes a label beside the control you insert. For example, when you add a text box, Access also inserts a label to the left of the text box. If you want to add multiple instances of the same type of control, double-click the appropriate but- TIP ton in the Controls group.The button remains pressed, and you can draw as many instances of the control as you need.When you’re done, click the control’s button to reset the control. Selecting Controls Before you can work with a control, you must select it. For a single control, you select it simply by clicking it. If you prefer to work with multiple controls, Access gives you a number of techniques: ■ Hold down the Ctrl key and click each control. ■ You also can “lasso” multiple controls by clicking and dragging the mouse. Move the mouse pointer to an empty part of the form, hold down the left button, and click and Manipulating Form Controls 31 drag. Access displays a box with a dashed outline, and any control that falls within this box (in whole or in part) is selected. ■ To select every control, choose Design, Select All in the Controls group (or press Ctrl+A). To exclude a control from the selection, hold down the Ctrl key and click inside the control. After you’ve selected multiple controls, you can set properties for all the controls at once (choose Design, Property Sheet). Note, however, that the Property Sheet pane shows only 2 those properties that are common to all the controls. Not only that, but if you size, move, copy, or delete one of the selected controls (as described in the next few sections), your action will apply to all the controls. Formatting Controls You saw in Chapter 1 that you can format all the controls on a form by applying one of the predefined AutoFormat layouts. That’s an easy way to work, but if the layout isn’t quite what you want, or if you want to create your own AutoFormat layout, you need to format the controls by hand. ➔ To learn how to apply an AutoFormat, see“Assigning an AutoFormat in Design View,”p. 19. (Chapter 1) You can format any control by selecting it (you can work with multiple controls, if need be) and using the lists and buttons in the Design tab (see Figure 2.1): ■ Use the lists and buttons in the Font group to format the control text as well as the background color of the control. ■ Use the lists and buttons on the right side of the Controls group to format the control’s outline (the Line Thickness, Line Type, and Line Color lists) and its Special Effect (Flat, Raised, Sunken, and so on). After you apply formatting to a particular type of control, you might want Access to use the same TIP formatting on all future controls of the same type that you add to that form.To set this up, click the control with the formatting you want to use, choose Design, and then click the Set Control Defaults button (it’s in the Controls group). Adding Conditional Formatting Access enables you to apply a particular font automatically when a control value meets a specified condition. This is called conditional formatting, and it’s a useful tool when you need to monitor one or more values. For example, if your form is used to input budget values, you may want to flag those values that are over a certain threshold (such as the original budget target). Similarly, if your form calculates a value—such as gross margin—you might 32 Chapter 2 Working with Form Controls want to flag results that come in below a target value. In both cases, you can set up the con- ditional formatting to display any anomalous values in, say, a red, bold font so that they stand out from the rest of the numbers. Use Control Wizards Figure 2.1 Use the lists and buttons in the Font and Controls groups to format the 2 selected control. You apply conditional formatting by following these steps: 1. Select the field to which you want the conditional format applied. 2. Choose Design, Conditional. Access displays the Conditional Formatting dialog box, shown in Figure 2.2. Figure 2.2 Use the Conditional Formatting dialog box to specify font formatting to apply to a control when a specific condition is met. 3. If you want to specify the format to use when the condition is not met, use the format- ting buttons in the Default Formatting group. 4. Select the type of condition you want to use: • Field Value Is—The condition is applied to the current value of the field or unbound control. In this case, you construct the condition by selecting a com- parison operator (such as Between or Less Than) in the second list and then entering one or two values (depending on the operator). • Expression Is—The condition is met when the logical expression you enter returns True. For example, if you enter Date()=#8/23/2007#, the formatting is applied only on August 23, 2007. • Field Has Focus—The condition is met when the field or unbound control has the focus (that is, when the cursor is inside the field). Manipulating Form Controls 33 5. Click the formatting buttons to specify the font formatting to apply to the control when the condition is met. 6. If you want to apply another condition, click Add and repeat steps 4 and 5 for the new condition. 7. Click OK. Sizing Controls An invisible rectangular frame surrounds each control. When you select a control, Access 2 displays selection handles at the frame’s corners and midpoints, as shown in Figure 2.3. Move handles Size to Fit Size to Grid Figure 2.3 Selecting a control displays the control’s selection handles. Selection handles You can resize any control to change its shape or dimensions. The following procedure outlines the steps to work through: 1. Select the object you want to size. 2. Position the mouse pointer over the selection handle you want to move. The pointer changes to a two-headed arrow. To change the size horizontally or vertically, use the appropriate handle on the middle of a side. To change the size in both directions at once, use the appropriate corner handle. 3. Click and drag the handle to the position you want. 4. Release the mouse button. Access redraws the object and adjusts the frame size. To reduce some of the drudgery of control sizing, Access also offers a number of automatic sizing techniques. The next few sections give you a quick tour of these techniques. Sizing to the Grid When you draw a control on the form, Access normally sizes the control so that it auto- matically lines up with the nearest grid mark. You can turn off this behavior by deactivating the Arrange, Snap To Grid button.
DMCA.com Protection Status Copyright by webtailieu.net