Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Oct 2001
    Location
    Perth, Western Australia
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    track active control (97)

    I have a hidden text box on my form and I want to store the Name value of the currently active control in that text box, but I don't to write a click event for every control.

    Any ideas?

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

    Re: track active control (97)

    If you don't use one of the control events, how were you planning to determine that the active control had changed? I usually get a form a custom string property called LastControl by creating a public module level variable by that name. Then in the gotfocus on OnClick event of each control I set the LastControl property to the name of the control. That will work even on labels, which can't receive the focus but do have a click event. Otherwise, you can use Screen.ActiveControl.Name to get the name of the active control, but you still have to trigger it from something.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Oct 2001
    Location
    Perth, Western Australia
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track active control (97)

    Thanks Charlotte

    Sorry it has taken so long to reply as I got side tracked by another project (as one does!) and I got to go on leave as well!

    Anyhow, I guess what I was getting at was that I didn't want to write a sub for each control but wanted instead something more global at the Form level to track the name of last focussed control.

    In the end I just wrote a click event for each control to put its name in the hidden text box as the text box's value. Probably not the most efficient way to do it, but, hey, I'm just a newbie.

    Thanks
    Dean

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

    Re: track active control (97)

    Otherwise, you'd have to use a class and bind each control to it in the form's Open event.
    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
  •