Access Queries   «Prev  Next»
Lesson 3 Displaying custom validation messages
Objective Set the Validation Text property to display a custom message.
Although setting the Validation Rule property does the job as far as validating your data, it does not present a very user-friendly message when you enter invalid data. The figure below shows you an example of a not-very-friendly message for a validation rule. In the example below, the Validation Rule property for the State field in the Clients table is set to AZ or TX. If the data entered into the State field is not one of these values, the message below appears.
 Access Invalid Data message
Access Invalid Data message

To present a more polite message, you need to set another property called Validation Text for the field. This property is located right below the Validation Rule property in the properties for the field. By typing the message you want displayed in the Validation Text property, you can make Access display that text instead of Access's more cryptic message.
You can see both the validation text setting and the resulting message displayed in the Slide Show below.

Setting Validation Text
There are a couple of things to keep in mind when specifying your Validation Text property. The first thing is to make the message friendly, because people may be frustrated already at putting in erroneous data. The other is to be as helpful as possible. For instance, in the validation text just displayed, the users are informed that they need to supply AZ or TX for the state requested.
This field would function better by using a lookup field, which naturally limits input using a Combo Box or List Box control. Lookup fields are discussed later in the module.
In the next lesson, you will learn how to use the Input Mask Wizard to specify data input formats.
Validating Data Fields - Quiz
Click the Quiz link below to answer a few questions about validating data in fields.
Validating Data Fields - Quiz