Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005

    Unanswered: Check if all validation conditions are met?

    I'm going through a host of different forms, most of which have a lot of field based validation rules and texts.

    While a per field validation rule is very nice, I was wondering if it was possible to do a check if all validation rules are met e.g. by a button, or "on close".

    I reckon I could loop through all controls on the form, but was hoping there was a simple way.

    Cheers, Trin
    IT squid: networks, servers, firewalls, routers and I dabble a little with SQL-server and Access as well....

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    validation depends on how you prefer to do it.
    you can use the per control technique (ie after a user has entered data into a control validate it, display a message and take appropriate action
    or use the validation after data capture of all controls.
    there isn't a huge amount of difference, you rind effectively the same code. you insert code in the control (or forms) 'before update' event and set cancel = true if there are errors.

    simple way... simple way for programming or maintenance. bear in mind most cost of the application over its life tiemj is maintenance, so writing code that is easy to understand and read is better than some whizzo code that save you a couiple of hours of development time but can be a nightmare to maintain overtime, even if its the same developer maintaining that code over time let alone some poor sap who has stepped into you shoes and is trying to work out how your mind works and how you code.There's a time for whizzo tricks and a time for simple cldear code, wrapped into fucntions so that they can be called from anywhere.

    FWIW my preference is the do all the data capture, then validate over validate per control. why most data entry users Ive come across prefer it, its also gracefully handles interlinked controls where as per control can stop the data entry in their tracks and doesn't easily handle interlinked controls. As part of that process I set background colour of controls to indicate require (yellow), error (red), orange for interlinked). with an error message stuffed into the controls tooltip if available

    There's no reason why you can't do the same thing using per control validation.. just that it can get messy if you have one piece of information form say 1 control out of 3... users don't like being told they have 2 more prices to complete when they are going to do that anyway in my experience. that means you have to structure you per control validation a bit more carefully and in some cases you will have to use a per form/row validation on top...but thats my personal preference you develop your own strategy
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2005
    I agree completely on the gathering point of view.

    I certainly also prefer to let the user enter all day, validate and then prompt for anything missing or errouneous. But rather than having to go through the form field by field, remove validation and programmatically do a validation func/sub, I wanted to cut corners in some way.

    Having written that I realize that I dont really wanna cut corners with regards to validation. Ugh.. need coffee.

    Cheers, Trin
    IT squid: networks, servers, firewalls, routers and I dabble a little with SQL-server and Access as well....

  4. #4
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Quote Originally Posted by healdem View Post can use the per control technique
    ...or use the validation after data capture of all controls
    ...there isn't a huge amount of difference...
    While it is true that you can do Validation for appropriateness of data at either the Control-level or at the Form-level, i.e. in the Form_BeforeUpdate event, if you are validating that one or more Controls actually have data, which is to say are not Null or empty, this must be done in the Form_BeforeUpdate event! Tying this type of validation to an event connected to the Control, such as the Control's BeforeUpdate event, is useless! If no data is entered into the Control, the events of the Control will never be executed! You can't even use the Control's OnExit event, because the user might not ever enter the Control!

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts