Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where's the Focus? (2002)

    Is there an easy way to find what has the focus. (Sometimes there is no cursor)
    I'm having problems transversing through forms and knowing where the focus is-especially when a new record is created etc. I get an error message on one that says I can't enter data at this time.
    When I use the tab to track down what control or form has the focus and transverse down the subforms etc. it still gives me errors.
    Frank

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

    Re: Where's the Focus? (2002)

    The Screen object has properties that you may find useful:

    Screen.ActiveForm returns the active form. Note: if the focus is on a subform, Screen.ActiveControl returns the main form that contains the subform. If no form or subform has the focus, an error occurs (error 2475 - you can trap for this). To get the name of the active form, use Screen.ActiveForm.Name.

    Screen.ActiveControl returns the active control. If no control has the focus, an error occurs (error 2474 - you can trap for this). To get the name of the active control, use Screen.ActiveControl.Name.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Where's the Focus? (2002)

    Do you want to be able to find the field with the focus visually or via code?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Where's the Focus? (2002)

    Both

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Where's the Focus? (2002)

    I personally like to change the background color of the control with the focus; I usually change it (then change it back) in the control's Get/Lost Focus events. Of course, this only works textboxes, combos, etc. As far as the controls with the focus goes, you can use Screen.ActiveControl to reference the control with the focus.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Where's the Focus? (2002)

    Thanks Mark I'll try it.

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Where's the Focus? (2002)

    Thanks Mark I'll try it.
    Frank

  8. #8
    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: Where's the Focus? (2002)

    <hr>Of course, this only works textboxes, combos, etc. <hr>

    Actually there is a way to show focus changes on continuous forms etc. using Access 2000 and above (uses conditional formatting)

    see attached demo.
    Attached Files Attached Files
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  9. #9
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Where's the Focus? (2002)

    >>Actually there is a way to show focus changes on continuous forms etc. using Access 2000 and above (uses conditional formatting)<

    Actually, you can easily show focus changes on continuous forms in any version of Access. The technique is simple, merely give each of your controls on the continuous form a background color that you want to use when the control has the focus, then make the backstyle=Transparent.

    You can even use a variation of this to highlight the current row in a continuous form! Follow the link below to my website to download a demo.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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