Microsoft Access Validation Of Data Using One Line Of CodeJuly 7, 2009 | 11:08 pm
Data validation checks that data are valid, sensible, and reasonable before they are processed. Microsoft Access validation can involve a time consuming choir if one had to do it for each control or ‘access field’, on each of your Access forms. Several have authored various approaches to automate Access validation for you. No single approach will work for all situations. Your form might allow a user to move off the record before Microsoft Access validation code is triggered. If you try to prevent the user from doing so, you will need to create additional design changes and add more complexity to your form.
I chose to take a conservative approach to Access validation, which works for most situations, but with a few more lines of code, will even prevent the user from leaving an unvalidated record no mater where he mouses to.
The user is notified if a form control failed validation, told why it failed, the control is highlighted briefly, and cursor focus is moved back to the failing control. Oh yes, it doesn’t try to validate form controls that come later, in the tab order, than where the user currently is. A single line of programming code is used on the OnOpen event of your form for this Microsoft Access validation of form data. The user can be prevented from navigating off the form record, adding a new record, or closing the form if validation fails, this requires an additional line of code on the appropriate form close, add new record and navigation buttons.
An Access developer just needs to enter a few characters into the ‘TAG’ property of a form’s control. The ‘TAG’ control property stores extra information about a control. The videos below will show you how to find this property in the ‘Property Sheet’ of the control you want to validate and will demonstrate the Access validation of a form using the code found from a link at the end of this article which moves you into the article containing the full programming code. There is no programming involved unless you wish to expand on the supplied code’s functionality.
Access Form Data Validation Demonstration Video:
You may get your example demostration file containing all code for Access 97, 2000, 2002, 2003, 2007 – Get File #51
This is where you will find all the Microsoft Access validation code in next article:
How to locate the Access Form Control ‘Tag’ Property for Access 97, 2000, 2002XP, 2003 video:
How to locate the Access Form Control ‘Tag’ Property for 2007 video: