Solved

Which Control Has The Focus?

Posted on 1998-12-02
7
211 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

729 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