• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Working with Forms > Validating Data Entry

Validating Data Entry

Data entry can be a long, tedious process, so it's only natural to expect that an incorrect value will sneak in occasionally, such as a name in a numbers-only field. Rather than blindly accept whatever users type in, you can verify that the data meets certain criteria.

To validate data entry:

1.
Click the field in which you want to validate data and click the Properties toolbar button.

We picked the CopyrightYear field in a database that tracks books in a library.

2.
In the Properties dialog box, click the Data tab ( Figure 4.36 ).

Figure 4.36. Click the Data tab to limit the number of properties displayed in the dialog box.


3.
Click Validation Rule, and then click the Build button that appears to the right of the property ( Figure 4.37 ).

Figure 4.37. Clicking Validation Rule (or the text box next to it) displays the Build button.


The Expression Builder appears ( Figure 4.38 ). The Expression Builder helps you create formulas that Access can use to evaluate and calculate data.

Figure 4.38. The Expression Builder is a powerful and flexible tool you can use to create your validation rule.


4.
Enter the expression you want Access to use as your validation rule. Click OK to continue.

In this case, we entered the rule ">1900" to ensure that we didn't type in an incorrect value. If we owned any books printed before 1901, we would have to modify the rule.

5.
Your validation rule appears in the Vali dation Rule property's text area. Close the Properties dialog box to save your validation rule ( Figure 4.39 ).

Figure 4.39. Now everyone can see your expression.


Tip

You can choose the message that you want displayed when a user enters incorrect data. To set this message, type it into the Validation Text property's text box.


Tip

If you click on the property's Build button after you've set a validation rule (if you wanted to edit it, for instance), the rule will appear in the Expression Builder's editing window when it opens.


  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint