Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Next Active Control (Access 2000)

    I have a field on a form that uses the 'Lost Focus' Event to validate the data entered. I want to cancel this event if the user clicks the 'Quit' application button. Is there a way to determine in the 'Lost Focus' of this field what control the user selected? The 'Got Focus' for the Quit command executes after the 'Lost Focus' of this field.

    Thank you
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Next Active Control (Access 2000)

    No, I don't think you can find out what the next control is going to be. But on the other hand, you know which was the previous control that had the focus, through Screen.PreviousControl, so you might be able to use that in the On Click event for the Quit button.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Next Active Control (Access 2000)

    Thanks Hans,

    That was what I figured after searching for hours.

    Have a nice day and thanks for sharing your knowledge with us.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  4. #4
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Next Active Control (Access 2000)

    If your 'field' on your form (I presume you mean textbox) is bound to an underlying field in a table, you might be better off using the BeforeUpdate event of that textbox (in which you can cancel the update). This also means that your validation code will only run if the data has been changed in the textbox - your LostFocus event will fire the code every time.

    Just a thought.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Next Active Control (Access 2000)

    Thanks Steve,

    Yes it is a textbox. The form is a log-in form and therefore unbound. I validate the id when the field loses focus and if the Id is not found in the user table then I use a msgbox informing then that the Id entered is invalid. It looks odd to see the message when the user decides to exit rather than log-in. I'll just have to add code elsewhere to display the message.

    Don
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

Posting Permissions

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