Daily Access Tips

Answering your common Microsoft Access questions…
  • rss
  • Home
  • About
  • Contact
  • Newsletter
  • Video Tutorials
  • Help Request Form

Microsoft Access Validation Of Data Using One Line Of Code

July 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:


from youtube

http://www.youtube.com/watch?v=otCMjARPiJY

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:

http://dailyaccesstips.com/code-for-microsoft-access-validation-of-data/

How to locate the Access Form Control ‘Tag’ Property for Access 97, 2000, 2002XP, 2003 video:

from youtube
http://www.youtube.com/watch?v=16HVabt2gM4


How to locate the Access Form Control ‘Tag’ Property for 2007 video:


from youtube
http://www.youtube.com/watch?v=hViGDmDU3P4



Bookmark and Share

Categories
Access Custom Functions, Access Forms, Programming Code
Comments rss
Comments rss
Trackback
Trackback

« Code For Microsoft Access Validation Of Data Automating Microsoft Access Email Alerts »

7 Responses to “Microsoft Access Validation Of Data Using One Line Of Code”

Newer Comments »
  1. jerry says:
    July 8, 2009 at 10:48 am

    There are problems with the HTML version of the code when copy/pasting into MSAccess.

    Opening and closing quotes as well as apostrophes (comments) are NOT the same in HTML as MSAccess; only standard double quote (“) is supported.

    Additionally, MSAccess inserts spaces in the string following an open quote; caution is required when correcting to standard double quote (“).

  2. Younis says:
    July 23, 2009 at 1:28 am

    Thanks Mr. Bob,

    I would like to ask about the code that can connect Access 2007 to SQL server or Oracle databases bu using VBA in access 2007

    thanks again,

    Younis

  3. admin says:
    July 23, 2009 at 9:40 am

    Unless your link will keep changing, just manually create the link in Access but first set up your ODBC data source to SQL Server using control panel administrative screen (For XP) Then link to the database in Access as you would any other outside data source.

  4. Debra says:
    July 23, 2009 at 12:07 pm

    Thanks for this information. I will pass this on to my tech team to check out.

  5. RANAJEET DUTTA says:
    April 9, 2010 at 9:50 pm

    Thanks Bob,

    This was really great. I am watching it over and over again to get the hang of it. Codes takes me a long time to learn.

Newer Comments »

Leave a Reply

Click here to cancel reply.

Categories

  • Access Custom Functions
  • Access Forms
  • Access Queries
  • Access Tables
  • Miscellaneous
  • Programming Code

Recent Posts

  • Access MVP Recognition
  • Microsoft Access 2010 Release News
  • Microsoft Access Security All Versions
  • Not For Null

Discounted Access Books

Get Discounted Access Books!

Bob Heifler

  • About
  • Contact
  • Newsletter
  • Video Tutorials

Access Resources

  • Microsoft Access Demonstration Files
  • Move data from Access to Excel
  • MyAccessProgram.com
  • Services Offered
  • Tips and Best Practices
  • Video Tutorials

Discounted Access Books

Get Discounted Access Books!

more help…

Microsoft Access Help

Bookmark and Share
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox