Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validation (WIN 2000 Acc 97)

    I have read (re-read) the archives concerning validation, and I am still confused. Maybe someone here can set me straight!
    I have a form with 8 required fields.
    There are several ways out of the record.
    1- Add new record button
    2- Close form button
    3- Find New Record button (Once user gets to found record, doesn

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validation (WIN 2000 Acc 97)

    How does the user get out of the form for AddNew and find new? Are they command buttons? If so, then I'd do what you were thinking of doing: write a function and call it from all of the places the user can get out. The command buttons for Add New, Find New, any way the user can close the form, etc.

    Or did I miss the question?

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Validation (WIN 2000 Acc 97)

    Validations are intended to happen when the user has added a new record or edited an existing one and they try to 1) save that record, or 2) move to another record, or 3) close or exited the form/subform. If the form is bound to a datasource and the current record is dirty, any of those 3 actions will trigger the BeforeUpdate event of the form. The BeforeUpdate event *does* have a Cancel argument, and setting it to True means that the record is not saved, the user does not move to another record and the form is not closed. In that routine, you can set the focus to the first control that has an illegal or missing value and force the user to either complete the record or cancel it entirely.

    When you validate a field is a matter of choice and style. Each data control has its own BeforeUpdate event, which can also be cancelled, but you have to be more careful about using those because you may only want to enforce a rule based on the value of another control and you can't count on them being entered in the "correct" order. There are also table level validations, which include enforcing a datatype, so the user can't enter text into a numeric field, for example

    If your user is managing to save a record with data missing, it isn't a case of the BeforeUpdate event not working properly, it's a case of your code not being written correctly. You have to test each required field evey time and the minute you find one that is illegal or missing, you immediately set Cancel = True and then notify your user of their mistake/oversight. If you don't set Cancel=True, the update will happen anyhow and you'll have to rely on table level validation, which may not help unless you have set those fields are required in the table itself.
    Charlotte

Posting Permissions

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