Show or hide rows in a repeating table by using conditional formatting

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 show or hide a row in a repeating table or repeating section, depending on whether the data in a row matches the value of a drop-down list box control. For example, if your form template has a repeating table that contains rows of products that fall into one of three classifications (A, B, or C), you can use conditional formatting to determine which rows are displayed, based on selections that users make on the form.

Note: You can use filters to enable users to show or hide information in a form. However, because filters aren't supported for browser-compatible form template, conditional formatting is a useful alternative to filters in browser-compatible form templates.

In this article

Step 1: Add the controls

Step 2: Specify the conditional formatting

Step 3: Preview the form template

Step 1: Add the controls

In order to complete this procedure, your form template must contain a list box and a repeating table. To add these controls, do the following:

  1. On the form template, click where you want to insert a list box and a repeating table.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Under Insert controls in the Controls task pane, click List Box, and then click Repeating Table.

  4. When you insert a repeating table, you will be prompted for the number of columns. Leave the default value at 3, and then click OK.

  5. Above the list box that you inserted on your form template, type a label that reads Filter by Type:.

  6. Type column labels in the first row of the repeating table, so that the first column reads Product, the second column reads Type, and the third column reads Price.

Top of Page

Step 2: Specify the conditional formatting

After you add your controls to the form template, you can specify the appropriate conditional formatting.

  1. Double-click the list box.

  2. Click the Data tab.

  3. Under List box entries, click Add.

  4. In the Value box, in the Add Choice dialog box, type A, and then click OK.

  5. Repeat steps 3 and 4 to add values for B, C, and D.

  6. In the list of values, select D, and then click Set Default.

  7. Select the repeating table on your form template, and then on the Format menu, click Conditional Formatting.

  8. In the Conditional Formatting dialog box, click Add.

  9. Under If this condition is true, in the first box, select the field that corresponds to the second column of the repeating table.

  10. In the second box, click is not equal to.

  11. In the third box, click Select a field or group.

  12. In the Select a Field or Group dialog box, select the field that corresponds to the list box that you inserted on the form template, and then click OK.

    Note: The condition will dynamically compare the two values.

  13. Under Then apply this formatting in the Conditional Format dialog box, select the Hide this control check box.

    Note: This condition now states that if the content of the second column of a repeating table row is different from what is selected in the list box, then the corresponding rows in the repeating table should be hidden.

  14. To return to the form template, click OK twice.

  15. Double-click the control in the second column of the repeating table.

  16. Click the Data tab.

  17. Type D in the Value box.

Top of Page

Step 3: Preview the form template

After you add conditional formatting to the form template, it is recommended that you test the changes to ensure that they are working properly.

  1. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

    Note: By default, the selection in the list box is D. You might need to scroll up in the text box to see the other values.

  2. To add a few rows to the repeating table, under the repeating table, click Insert item several times.

  3. For each row in the second column of the repeating table, replace the default value of D with A, B, or C.

    Note: The expressions are case sensitive.

  4. Change the selection in the list box. The rows in the repeating table will appear and disappear as you select different options.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×