To validate a value entered in a field, record, or control, you create a validation rule and then define the text that you want to display when the data entered doesn't meet that rule. For example, you might create a rule that says all dates entered must be in 1998.
There are several ways that you can define validation rules in Microsoft Access. This topic provides reference information about:
Form-level validation with macros or Visual Basic for Applications
You can ensure that data is entered correctly into a field by defining a field validation rule. A field validation rule is used to check the value entered into a field as the user leaves the field. A message you define is displayed if the value breaks the validation rule. You define a field validation rule in a table.
Return to top
A record validation rule controls when an entire record can be saved. Unlike field validation rules, record validation rules can refer to other fields. This makes them useful when you want to compare values from different fields in a table. You define a record validation rule in a table.
Return to top
You can also define a validation rule in a control on a form. In most cases, it's best to define the validation rule for the field in the table, because any field validation rule is automatically applied to a control based on that field (as long as you create the control after defining the validation rule in table Design view). But you must define the validation rule in the control if the control is unbound or if the control is based on data in a linked (external) table. You must also define the validation rule in the control if the validation rule refers to fields or controls in other forms, or if the validation rule contains domain aggregate functions, aggregate functions, user-defined functions, or the CurrentUser or Eval function.
Return to top
There are also situations where you must use macros or Visual Basic for Applications code in conjunction with a form to perform more complex validation. For example, you might want to be able to override your validation rule under certain circumstances or compare values from different tables.
Return to top