Creating Validation Rules


If you have more complex validation requirements, you probably want to consider using validation rules, which are sets of criteria that you can establish. If the value entered into the field does not meet that criteria, you can trigger either an error message inline with the field or an error message that is visible through an alert box, as described earlier.

Validation rules are created at the object level; in other words, rules are associated with the individual data entry controls that are present on your form. To create a new validation rule, right-click an object and select Properties.

On the Data tab of the Properties dialog box, click the Data Validation button to open the dialog box shown in Figure 9-3.


Figure 9-3: Data validation options

Click the Add button to open the Data Validation dialog box, shown in Figure 9-4.

click to expand
Figure 9-4: Validation rule options

The way that validation rules work is that you can select a data entry control, or a field or a group of fields that appear within your data source and use a number of operators (Is Equal To, Starts With, and so on) to make a comparison against a value you enter or the contents of another field.

For example, you may have a Travel Request form with a numeric data entry control for the user to enter the travel advance they would like to receive. This object could have a criteria set so that if the user enters an amount over $500, an inline error or dialog box would be shown, indicating that the form couldn’t be used to authorize these amounts.

The criteria in this case would be similar to the one shown in Figure 9-4, which specifies that if the condition is true that the advance_amount field is greater than or equal to 500, then the user receives an error alert stating that the form can only be used to request travel advances less than $500.

At a basic level, you can establish one set of criteria to check using the dialog box provided, or you can use the Add button to add extra criteria. Continuing the preceding example, you may want to allow people who have the title of “Manager” to request a larger travel advance. In this case, your criteria might look similar to the dialog box shown in Figure 9-5.

click to expand
Figure 9-5: Compound validation rule criteria

By default, the relationship between multiple validation rule criteria is And, but you can use the drop-down list provided to change this to Or. If you no longer need one of the sets of validation criteria you have added, you can use the Delete button to remove it from your rule.

So that you can learn how to create the different types of validation rules, the following section presents the different types of validation operators that you can use and leads you through some examples of where you would use each.




How to Do Everything with Microsoft Office InfoPath 2003
How to Do Everything with Microsoft Office InfoPath 2003 (How to Do Everything)
ISBN: 0072231270
EAN: 2147483647
Year: 2006
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net