Validate data by using an event procedure
- Open the form in Design view.
- Create the event procedure for the event that you want to trigger the validation.
How?
For example, to trigger the validation rule when a control is updated with changed data, create an event procedure for the control's BeforeUpdate event.
- Add Visual Basic for Applications code to the event procedure, specifying the validation condition and the operations to perform when those conditions are met.
Tips
- It's usually a good idea to cancel the event that triggers the validation after the operations have been performed. You can cancel many events by setting the event procedure's Cancel argument to True.
- To validate data before the record as a whole is updated, add code to the BeforeUpdate event procedure for the form, rather than the control.
For an example of validating data by using an event procedure, click .
For information about the events used for data validation, click .
For information about the order of validation for controls and fields, click .