Retain focus after update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Birky
    New Member
    • Dec 2006
    • 52

    Retain focus after update

    I have a form in which I have a text object where I have some VBA code on the after update to verify the input. If the input does not match the standard then I would like to put the focus back on that field so the user can reevaluate the data. I am unable to get Access to put the focus back on this object when the data does not fit the standard. Is there a trick to giving the object the focus when this condition arises?

    I am working with software version and therefore have implemented some validation via VBA to ensure the user is not inserting bogus information. I have everything working except I’m unable to find a way to place the focus on this filed since it was the object that had the focus.

    Any help would be greatly appreciated.
    Birky
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by Birky
    I have a form in which I have a text object where I have some VBA code on the after update to verify the input. If the input does not match the standard then I would like to put the focus back on that field so the user can reevaluate the data. I am unable to get Access to put the focus back on this object when the data does not fit the standard. Is there a trick to giving the object the focus when this condition arises?

    I am working with software version and therefore have implemented some validation via VBA to ensure the user is not inserting bogus information. I have everything working except I’m unable to find a way to place the focus on this filed since it was the object that had the focus.

    Any help would be greatly appreciated.
    Birky
    Birky,
    You should be using a Before Update event for data validation. The Before Update event allows you to cancel the update if the input is not in accordance with your validation rules. See the following link for sample code on how it works. Click the hyperlink on the web page that says "confirm changes using the Before Update event. The bottom of the next web page has topics such as validating data in textboxes and using the undo statements.

    Comment

    • Birky
      New Member
      • Dec 2006
      • 52

      #3
      Thanks much; I was totally in the wrong frame of mind with this one. Once I moved the code over to the before update I was able to stop the user in their tracks to have them reevaluate. I truly appreciate you help and for setting my on the right track.

      Birky

      Comment

      Working...