How to check whether the values of all fields in a Repeating Table in InfoPath have been set

This article shows you how to use Data Validation rules or Conditions on Rules in InfoPath to check whether all of the fields in a repeating table on an InfoPath form contain a value.

ADVERTISEMENTS

Problem

You have a Repeating Table on an InfoPath form and you want to check whether the user has filled out all of the fields in the Repeating Table.

Solution

Use Data Validation rules if you want to check whether the values of all fields in the Repeating Table have been set just before the InfoPath form is submitted. In this case you'd want to prevent the user from submitting the form if all of the values in all of the rows of the Repeating Table have not been filled out.

Use Rules and Conditions if you want to check whether the values of all fields in the repeating table have been set before the user performs another action on the form. In this case you'd want to prevent the user from performing a certain action on the form if all of the values in all of the rows of the Repeating Table have not been filled out.

Discussion

InfoPath Basics: 3 Ways to validate data in InfoPath discusses the basics of using data validation in InfoPath. You can apply those basics here.

The values in the Repeating Table can be validated on two ocassions:

  1. Just before the InfoPath form is submitted.
  2. Before the user performs another action on the InfoPath form after filling out the Repeating Table.

In the first case, it is best to use Data Validation rules, although Rules and Conditions could also work. In the second case, your only option is to use Rules and Conditions, because Data Validation rules can only prevent a form with invalid data from being submitted. Data Validation rules cannot prevent a user from continuing to fill out a form, despite validation errors being present on the form.

Both solutions work in browser-compatible InfoPath forms.

Use data validation rules to check whether all values have been set in a Repeating Table

  1. In InfoPath, create a new Blank form template.
  2. Add a Repeating Table control to the form template.
  3. Right-click on a field in the Repeating Table and select Data Validation from the context menu.
  4. On the Data Validation dialog box, click Add.
  5. On the Data Validation dialog box where you can enter a condition, enter a condition that says:

    field1 is not blank

    where field1 is one of the fields in the Repeating Table. By setting this data validation condition, the values of all of the field1 fields in all of the rows of the Repeating Table will be validated.

  6. On the Data Validation dialog box where you can enter a condition, fill in the ScreenTip and Message text boxes, and then click OK.
  7. Repeat steps 4 through 6 for all of the fields in the Repeating Table.
  8. On the Data Validation dialog box, click OK.

You should now have a fully functional form so that a red star (indicating that the fields are required) appears in the fields of the Repeating Table until they have been filled out. A user will not be able to submit the InfoPath form until the values in all of the rows of the Repeating Table have been set.

Use rules and conditions to check whether all values have been set in a Repeating Table

  1. In InfoPath, create a new Blank form template.
  2. Add a Repeating Table control, a Button control, and a Text Box control to the form template.
  3. Double-click the Button control to open its Properties dialog box.
  4. On the Button Properties dialog box, click Rules.
  5. On the Rules dialog box, click Add.
  6. On the Rule dialog box, add an Action that says:

    Set a field's value: field4 = ""

    where field4 represents the Text Box control that you added in step 2.

  7. On the Rule dialog box, click OK.
  8. On the Rules dialog box, click Add.
  9. On the Rule dialog box, add an Action that says:

    Set a field's value: field4 = "There are empty fields in the repeating table"

    where field4 represents the Text Box control that you added in step 2.

  10. On the Rule dialog box, click Set Condition and add a condition that says:

    field1 is blank
    or
    field2 is blank
    or
    field3 is blank

    where field1, field2, and field3 represent the controls in the Repeating Table control that you added in step 2.

  11. Click OK to close all open dialog boxes.

You should now have a fully functional InfoPath form so that when you click the button and have not filled out all of the values in all of the rows of the Repeating Table, the text There are empty fields in the repeating table will appear in the Text Box.

Note: This rule could also be added on a control other than a button so that the checking is done when the value of a field changes instead of when a button is clicked.

 
 Subscribe for updates via RSS or Email

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services