Validate data by using a macro

Validate data by using a macro

  1. Create a macro.

    How?

  2. In the Macro window, make sure Conditions on the toolbar is pressed in.

  3. In the Condition column of a blank action row, enter a validation condition.

  4. In the Action column, click the action in the action list that you want to carry out if the validation condition is true.

  5. For any additional actions you want to carry out if the validation condition is true, enter an ellipsis (...) in the Condition column followed by the action in the Action column. For example, it's usually a good idea to carry out a CancelEvent action for each validation condition after any other actions have been carried out.

  6. Click Save to save the macro.

  7. Open the form in Design view.

  8. For the event that you want to trigger the validation, set the event property to the name of the macro. For example, to trigger the validation when a control is updated with changed data, set the BeforeUpdate event property of the control to the name of the macro.

    Tip   To validate data before a record as a whole is updated, attach the validation macro to the form's BeforeUpdate event rather than to the control's BeforeUpdate event.

For an example of validating data by using a macro, click .

For information about the events used for data validation, click .

For information about the order of validation for controls and fields, click .