How to create a toggle button in InfoPath using rules and conditions

Applies to: InfoPath 2007

This article shows how you can create a toggle button in InfoPath using only rules and conditions; no code.

ADVERTISEMENTS

Problem

You have a repeating table with a check box control in the first column of the repeating table. You want to be able to click a button and automatically select the check boxes in the first column of all of the rows of the repeating table if the check boxes are unchecked, and vice versa if they are checked.

Solution

Use rules and conditions to create a toggle button that selects and deselects check boxes in a repeating table.

Discussion

You can achieve this functionality as follows:

  1. Add a Repeating Table control to the InfoPath form template.
  2. Right-click the field in the first column of the repeating table and select Change To and then Check Box.
  3. Double-click the Check Box control to open its Properties dialog box.
  4. On the Check Box Properties dialog box, select True/False (boolean) from the Data type drop-down list box, select 0 from the Value when cleared drop-down list box, select 1 from the Value when checked drop-down list box, and click OK.
  5. Add a Button control to the InfoPath form template.
  6. Double-click the Button control to open its Properties dialog box.
  7. On the Button Properties dialog box, click Rules.
  8. On the Rules dialog box, click Add.
  9. On the Rule dialog box, add an action that says: Set a field's value: field1 = 1

    where field1 represents the check box control in the repeating table.

    Add a condition for this rule that says:

    field1 = "0"

    And select the Stop processing rules when this rule finishes check box.

  10. Click OK.
  11. On the Rules dialog box, click Add.
  12. On the Rule dialog box, add an action that says: Set a field's value: field1 = 0

    where field1 represents the check box control in the repeating table.

    Add a condition for this rule that says:

    field1 = "1"

    And select the Stop processing rules when this rule finishes check box.

  13. Click OK to close all open dialog boxes.
  14. Test the InfoPath form template.

Now whenever you click the button all of the check boxes in the first column of all of the rows of the repeating table will be checked if they are unchecked, and unchecked if they are checked.

 


Related InfoPath Articles:

 

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. 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.

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