Overview
Microsoft Access
This article explains how to use validation rules and validation text in table fields and form controls. A validation rule is one way to restrict input in a table field or a control (such as a text box) on a form. Validation text lets you provide a message to help users who input data that is not valid.
When data is entered, Access checks to see whether the input breaks a validation rule – if so, the input is not accepted, and Access displays a message.
Access provides a number of ways to restrict input:
-
Data types Every table field has a data type that restricts what users can enter. For example, a Date/Time field accepts only dates and times, a Currency field accepts only monetary data, and so on.
-
Field properties Some field properties restrict data input. For example, the Field Size property of a field restricts input by limiting the amount of data.
You can also use the Validation Rule property to require specific values, and the Validation Text property to alert your users to any mistakes. For example, entering a rule such as >100 And <1000 in the Validation Rule property forces users to enter values between 100 and 1,000. A rule such as [EndDate]>=[StartDate] forces users to enter an ending date that occurs on or after a starting date. Entering text such as "Enter values between 100 and 1,000" or "Enter an ending date on or after the start date" in the Validation Text property tells users when they have made a mistake and how to fix the error.
-
Input masks You can use an input mask to validate data by forcing users to enter values in a specific way. For example, an input mask can force users to enter dates in a European format, such as 2007.04.14.
You can use these methods of validating data alone or in combination with each other. Data types are not optional, and provide the most basic type of data validation.
OR