Add a rule
When designing a form, you can use rules to automatically display a dialog box, set a field's value, query or submit to a data connection, switch views, or open or close a form in response to certain events and conditions. The events can include a change to a particular field or group in the data source, the click of a button, the insertion of a repeating section or row in a repeating table, or the opening or submission of a form. The conditions can include whether the value of a field is blank, is within a specified range, equals the value of another field, or starts with or contains certain characters.
You can also add multiple actions for each rule. For example, you can automatically open a new form and display a dialog box message when a field's value exceeds 100.
- In design mode, do one of the following:
- To run the rule when a particular field or group in the data source is changed, open the Data Source task pane, double-click the field or group, and then click the Rules tab.
- To run the rule when the value of a control is changed, double-click the control, and then on the Data tab in the Control Properties dialog box, click Rules.
- To run the rule when the form is opened, click Form Options on the Tools menu, click the Open and Save tab, and then click Rules.
- To run the rule when a button is clicked, double-click the button, click Rules and Custom Code in the Action list, and then click Rules.
- To enable the form's default submit command to run the rule, click Submitting Forms on the Tools menu, and then click Enable Submit commands and buttons. In the Submit to list, click Custom submit using rules, and then click Rules.
- In the Rules dialog box or on the Rules tab, click Add.
- In the Name box in the Rule dialog box, type a name for the rule.
- To specify a condition for when the rule should run, click Set Condition, and then enter the condition. The rule will run when the event specified in step one occurs and the condition specified in this step is met.
- Click Add Action.
- In the Action list in the Action dialog box, click the action you want, and then enter the options for that action.
- Repeat steps 5 and 6 for each action you want to run for this rule.
- If you want to prevent any rules from running after this rule (for the current event), select the Stop processing rules when this rule finishes check box.
Note The information in this topic may not apply if you are working with a form designed using Microsoft Office InfoPath 2003 without the service pack installed. Learn more