Microsoft InfoPath Tutorial: Section 6 Overview
In this section, you will learn about:
- Customizing Controls
- Adding a validation rule
- Binding controls
- Populating controls from a data source
- Adding buttons to your form
Managing Controls
Customizing Controls
You can customize a control to display a specific format for your data, such as a currency or date format, as well as alternate text to ensure your form is accessible to all users. You do this by defining the control’s properties:
- Double-click the control.
This opens the Properties dialog for that control:
- It’s a good practice to give each field an identifiable name. If you plan to use the XML data source InfoPath creates by default, you can do this when you format the controls: enter a name that describes the contents of the field into the Field name field on the Data tab.
- Specify how the data in the field should be displayed by selecting a data type and then clicking the Format button. For example, to format a date field to display only the month and the year, select the Date option from the Data type menu and then click the Format button. In the Format dialog, select March, 2001 and click OK.
- Select the Display tab.
- Select any formatting options you want. For example, if you want a text box to be multi-line, select the Wrap text checkbox. This enables the Scrolling menu, which lets you select a scrolling option.
- To prevent the user from modifying the data in the control, select Read-only.
- Selecting Enable auto-complete enables the auto-complete feature, so when the user starts to type in the field, InfoPath can provide suggestions based on previous entries.
- To format the size and margins of the control, select the Size tab.
- Define the control’s size. For example, you might want to increase the height of a multi-line text box.
Tip:
You can quickly change the width of a control on a form by dragging its right edge:
- To add accessibility options, such as a screen tip, select the Advanced tab.
Enter a ScreenTip, tab index, and shortcut key for the control.
- When you’ve finished formatting the control, click OK.
To see how text will look when the user completes the fields, select Sample Data from the View menu. This toggles the sample data display in the fields on and off.
Tip:
To set a control to display in bold text, select the control and click the Bold button on the Formatting toolbar. You can use the same method to format other font properties for the control, such as size and color.
Adding a Validation Rule
It’s a good idea to add data validation to your controls. This displays warnings when the user completes a field with data that the database can’t accept, or that will in some way make it more difficult for the data to be analyzed later.
You add a data validation rule using the control’s Properties dialog:
- Double-click the control.
- In the Properties dialog, make sure the Data tab is selected.
- Under Validation, check Cannot be blank if you want to require the user to complete the field.
- Click the Data Validation button.
This opens the Data Validation dialog, which lets you add specific rules for validation.
- To create a validation rule, click the Add button.
- Use the dialog that opens to create your validation rule.
By default, the current field is selected as the field containing the data to be validated. Use the second and third drop-down menus to specify the conditions you want checked.
Then, under the error alert section, specify whether you want the error alert shown to the user to take the form of an inline alert (a screen tip and message) or a dialog box. Enter the alert text you want displayed.
When you’ve finished, click OK.
- Click OK to return to the Properties dialog.
- Click OK to close the Properties dialog.