Results 1 to 7 of 7
  1. #1
    SemiAuto40 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41

    Proper Error Trapping

    Seems like I have read places that error trapping is supposed to be done on the After_Update of the same field. For some reason mine does not work because after the first time through the trap then a user can just 'Enters through it' on to the next field! User is not trapped into circling back through the same field until a valid entry. The only way that I have been able to do what I want above is to do all of my error trapping in the on_gotFocus of the next field, which then sets the focus back to the prior field and the loop works just fine. I'm concerned that I am doing things bass-ackwards.
    Does it matter?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Hi
    I think you need to use the BeforeUpdate event which can be cancelled
    with Cancel = True
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I agree with Bob, and would point out that you're confusing validation:

    http://www.baldyweb.com/BeforeUpdate.htm

    with error trapping, which can (should?) be done in all procedures:

    http://www.baldyweb.com/ErrorTrap.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    SemiAuto40 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41
    As I try to use the validation on the form before_update, the validation is not done until all of the form fields are filled out - I suppose all of the validation for all of the form's fields will reside in the before_update sub? *But isn't it better for the user to be flagged at each field if an invalid entry is made and looped back into the invalid field?
    I'm just asking because I don't especially know what I am doing since I'm learning as I go along. Thanx for ALL answers great and small.

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Use the BeforeUpdate event of the Control
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    SemiAuto40 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41

    Exclamation

    Quote Originally Posted by Bob Fitz View Post
    Use the BeforeUpdate event of the Control

    I'm slowly starting to see my problem with validation.

    On my initial cbox at top of the form I assign a default value of "?????" for my ProductName_cbox. When I do an if statement in that control's before_update button BUT my user just presses the <Enter> key then the ProductName_cbox BeforeUpdate event never happens at all and the focus goes down to the Abort_btn.

    So either I'm missing something (likely) or on the BeforeUpdate of the control on a cbox is not the place for my validation. Am I wrong?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, as it's name implies the before update event only fires if something has been updated. Simply tabbing through the control won't fire it. That's one reason we use the form's before update event. Though it also won't fire if nothing was updated, it will catch any new records or changes to existing records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Append query error trapping
    By tpcervelo in forum Programming
    Replies: 4
    Last Post: 12-22-2011, 10:57 AM
  2. Ensuring Proper Data Entry
    By skg in forum Forms
    Replies: 5
    Last Post: 01-27-2011, 10:12 PM
  3. Form and Subform error trapping
    By usmcgrunt in forum Forms
    Replies: 8
    Last Post: 09-12-2010, 11:54 AM
  4. Setting the Default Value and Proper Case Example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-27-2010, 07:43 PM
  5. Proper way to store Names
    By trb5016 in forum Database Design
    Replies: 5
    Last Post: 08-22-2010, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums