Why use a macro or an event procedure for data validation?
In most cases, you can verify that data is entered correctly into a control on a form by setting the ValidationRule property for the control, or by setting record or field validation rules in the underlying table to which the control is bound. Macros and event procedures provide additional power and flexibility for more complex validation.
Use a macro or an event procedure for data validation if:
- Your validation rule involves conditions for more than one value on the form. For example, you might want to verify that any two of three fields are filled in before saving a record.
- You want to display different error messages for different types of errors in the field. For example, if the value entered is greater than the acceptable range, you can display one message, and if it's less than the acceptable range, you can display a different message.
- You want the user to be able to override your validation rule. In this case, you can display a warning message asking the user to confirm the data.
- The validation involves references to controls on other forms or contains a function.
- You have a validation rule that you can use for more than one form, and you want the convenience of defining the rule once and then referring to it in each form.
For more information about creating a macro, click .
For more information about customizing an event procedure, click .