Which Control has the Focus??

  • Thread starter Thread starter Ken Soenen
  • Start date Start date
K

Ken Soenen

Is there a way (Software-wise) you can determine which control on a form
currently has the Focus??

Thanks,
ken
 
Take a look at ActiveControl in VBA's help.

I put a bunch of controls on a userform, then used this code to display the
activecontrol's name:

Option Explicit
Private Sub CommandButton1_Click()
MsgBox Me.ActiveControl.Name
End Sub
Private Sub UserForm_Initialize()
With Me.CommandButton1
.TakeFocusOnClick = False
End With
End Sub
 
Thanks Dave. This is exactly what I need. In the future I have to pay more
attention to the PROPERTY/METHOD list that drops down after typing the
period. It shows the ActiveControl property there but it doesn't show it in
the Property Window(where I normally look).

ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top