Solved

Which Control Has The Focus?

Posted on 1998-12-02
7
199 Views
Last Modified: 2011-09-20
Is there a way to find out which control on a certain form currently got the focus?
0
Comment
Question by:lyka090898
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1447798
Use the Screen.ActiveControl
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1447799
explain more please

0
 
LVL 14

Expert Comment

by:waty
ID: 1447800
the Screen.ActiveControl always contains the control wich has the current focus in your application.

Screen.ActiveForm contains the form wich the focus.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 3

Expert Comment

by:traygreen
ID: 1447801
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
 

Author Comment

by:lyka090898
ID: 1447802
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
 
LVL 3

Accepted Solution

by:
traygreen earned 50 total points
ID: 1447803
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
 
LVL 14

Expert Comment

by:waty
ID: 1447804
How you want, but the more general way (I use it always) is using the screen.ActiveControl
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question