Validate Data

Forms that use a database or web service as their primary data source can send data back to that source through the Submit action. You can call the Submit action by choosing File Submit or by clicking a button on the form assigned to Submit.

Checkbox in this dialog determines whether the database is queried at form load

Figure 7-29. Checkbox in this dialog determines whether the database is queried at form load

Adding a button to refresh lists

Figure 7-30. Adding a button to refresh lists

Before submitting, however, you should validate the data to make sure the entries are valid for constraints in the database (or web service). InfoPath can validate fields using a variety of criteria. Problems are flagged and must be fixed before continuing, as shown in Figure 7-31.

InfoPath flags validation errors and highlights required fields

Figure 7-31. InfoPath flags validation errors and highlights required fields

How to do it

To add validation criteria to a control:

  1. Display the control’s properties and click Data Validation. InfoPath displays the Data Validation dialog, as shown in Figure 7-32.

  2. Click Add. InfoPath displays the dialog box for validation criteria. Enter a condition that results in a validation error. For example, the settings in Figure 7-33 make CustomerID a required field.

  3. Click OK, then preview the form and test the validation. ...

Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.