Results 1 to 9 of 9
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    best event for general use...keydown or on exit


    Ok so i think i know the answer to this stupid question already... but ill ask anyway.

    Background: - Self taught at access, built small apps for myself for home, currently building a "bigger one" for my work.

    Always used "on keydown, keycode = 13" for any process where data was entered...
    Dont ask why.. as i dont know.


    Just had a few issues and i said to myself... why arent i just using on exit...
    Then it wont matter if people click out of the box, press enter, or press shift (*my current issue)

    ... Am i correct in saying that in general "on exit" is the "best" event to use for general data input, eg "correct date", "@ missing in email" , "too few digits" etc etc ?

    i was also thinking after update, but if you want it to run every time, even if the data hasnt changed.. then on exit seems the way to go, and i have a lot of code to fix ahahah

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    For data validation before committing to field or table, most experienced developers use BeforeUpdate event. But if you want data validated every time the control gets focus, then Exit or LostFocus seem appropriate.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Thanks heaps June7 in to rescue me again!

    One question, (and i did look up the stuff on google but dont 100% understand)
    - If i use on exit and/or before update, is the data in .value or in .text form still??

    What i want is to do things and just use .value or .text and no have to mess around with both..

    So if i press enter and the control exits, and im using the before update event then do i use if [control].text or just [control]??

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I've never used .Text property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    So if i press enter and the control exits, and im using the before update event then do i use if [control].text or just [control]??
    With regards order of events - you may find this link useful

    https://support.office.com/en-ca/art...86553682f9#bm1

  7. #7
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    thanks guys!

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    For certain things I use the BeforeUpdate for the Form. For other things I use the AfterUpdate on controls. I will sometimes use both the OnExit and AfterUpdate events of controls, together. I do not use the BeforeUpdate event of controls because it can leave the application/form locked until the user enters information into the control that allows the BeforeUpdate code to successfully execute. I recommend avoiding BeforeUpdate for controls.

  9. #9
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    THanks ItsMe.

    So I'm now using pretty much as suggested, After and OnExit with controls and Before with some.

    Im still using keydown with a couple of search boxes and that is working really well.

    Was a BIG task going from keydown to update events but has been a fruitful excerise! Lots of learning done

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

Similar Threads

  1. Help with Validation code on exit event on a form
    By thebionicredneck2003 in forum Programming
    Replies: 2
    Last Post: 05-17-2013, 06:04 AM
  2. Replies: 2
    Last Post: 12-20-2012, 03:06 PM
  3. OnClose event and exit/quit buttons
    By atran in forum Access
    Replies: 1
    Last Post: 07-24-2012, 04:14 PM
  4. Replies: 2
    Last Post: 04-21-2012, 11:17 PM
  5. How do I capture Access DB exit event
    By jscriptor09 in forum Access
    Replies: 3
    Last Post: 09-21-2011, 09:45 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