In Microsoft Office InfoPath, you can use conditional formatting to specify different formatting options for a control that is based on conditions that occur on the form. If the specified conditions are true when a user fills out a form that is based on your form template, the conditional formatting is applied.
This article explains how to use conditional formatting to change the background color of a row in a repeating section. This is useful if you want to show the status of an item in the repeating section. For example, in a status report form template, you can use conditional formatting to make the row for an item that is behind schedule red, and the row for an item that is on schedule green.
Note: This article uses color to demonstrate a procedure. However, some users cannot discern colors. To create an accessible form template, be sure to also add meaningful text to your form template to indicate the status of an item.
In this article
Step 1: Add your controls
In order to complete this procedure, your form template must contain a repeating section, a text box, and a drop-down list box. To add these controls, do the following:
-
On the form template, click where you want to insert a repeating section.
-
If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.
-
In the Controls task pane, select the Automatically create data source check box.
-
Under Insert controls, click Repeating Section.
-
Place the insertion point in the repeating section.
-
Under Insert controls in the Controls task pane, click Text Box.
-
Press ENTER, and then under Insert controls, click Drop-Down List Box.
-
In the form template, type Work Item: as the label for the text box, and type Status: as the label for the drop-down list box.
-
Double-click the drop-down list box on the form template.
-
Click the Data tab.
-
Under List box entries, click Add.
-
In the Value box in the Add Choice dialog box, type Active, and then click OK.
-
Repeat steps 11 and 12 to add Resolved and Closed as choices in the drop-down list box.
Step 2: Specify the conditional formatting
After you add your controls to the form template, you can specify the appropriate conditional formatting.
-
Select the repeating section in the form template, and then on the Format menu, click Conditional Formatting.
-
In the Conditional Formatting dialog box, click Add.
-
Under If this condition is true, in the first box, click the field that corresponds to the drop-down list box that you just inserted.
-
In the second box, leave the value as is equal to.
-
In the third box, click Type text, and then type Active.
Note: The expressions are case sensitive.
-
In the Shading list under Then apply this formatting, click red, and then click OK.
-
Repeat steps 2 through 6 to add conditional formatting for the two remaining list entries. Select yellow as the background color for Resolved and green as the background color for Closed.
Step 3: Preview the form template
After you add conditional formatting to the form template, it is recommended that you test the changes to make sure that they are working properly.
-
To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.
-
In the preview window, select the different options in the drop-down list. Notice that as you select the options, the background color in the section changes accordingly.
-
On the Insert menu, point to Section, and then click the section name to add an additional section. Notice that the conditional formatting is applied independently to both sections.
No comments:
Post a Comment