Solved

Which Control Has The Focus?

Posted on 1998-12-02
7
157 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
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now