You can use a macro or an event procedure to validate data being entered in a form either by creating a macro that responds to an event on the form or by creating event procedures.
Validate data by using a macro
Validate data by using an event procedure
Learn more about using a macro or an event procedure for data validation