• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Which Control Has The Focus?

Is there a way to find out which control on a certain form currently got the focus?
0
lyka090898
Asked:
lyka090898
1 Solution
 
watyCommented:
Use the Screen.ActiveControl
0
 
InteqamCommented:
explain more please

0
 
watyCommented:
the Screen.ActiveControl always contains the control wich has the current focus in your application.

Screen.ActiveForm contains the form wich the focus.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
traygreenCommented:
Typically you trap to find the information re the ActiveControl.
Eg you have an array of text boxes (named txtInfo) and a combo box (named cboMyCombo) and wanted to trigger one of the controls events.  The code would look something like this....

Select Case UCase(ActiveControl.Name)
   Case "TXTINFO"
      Call txtInfo_LostFocus(ActiveControl.Index)

   Case "CBOPMYCOMBO"
      Call cboMyCombo_Click
End Select
0
 
lyka090898Author Commented:
waty, I believe that traygreen has provided a more explanatory answer.

so, traygreen, please post your comment as a proposed answer to get the points.
0
 
traygreenCommented:
Comment
       From: traygreen
                                                                              Date: Wednesday, December 02 1998 - 09:29AM PST

       Typically you trap to find the information re the ActiveControl.
       Eg you have an array of text boxes (named txtInfo) and a combo box (named cboMyCombo) and wanted to trigger one of the
       controls events.  The code would look something like this....

       Select Case UCase(ActiveControl.Name)
          Case "TXTINFO"
             Call txtInfo_LostFocus(ActiveControl.Index)

          Case "CBOPMYCOMBO"
             Call cboMyCombo_Click
       End Select
0
 
watyCommented:
How you want, but the more general way (I use it always) is using the screen.ActiveControl
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now