Which control has focus?

  • Thread starter Thread starter Mark A. Sam
  • Start date Start date
M

Mark A. Sam

Hello,

Is there a way to detect which control on a form has the focus?

Thank you and God Bless,

Mark A. Sam
 
Mark A. Sam said:
Hello,

Is there a way to detect which control on a form has the focus?

Thank you and God Bless,

Mark A. Sam

Hi Mark,

You can use Screen.ActiveControl

HTH
SteveC
 
Screen.ActiveControl returns a reference to the actual control:
Screen.ActiveControl.Name will return its name.
 
Mark said:
Is there a way to detect which control on a form has the focus?


If you know which form contains the control, then use the
form object's ActiveControl property. E.g. if the code is
in the same form as the control, then use Me.ActiveControl.

If the code has no idea which form contains the control,
then you will have to use Screen.ActiveControl
 
Thanks for the help. I used Me.ActiveControl.Name.

I never used the ActiveControl property outside of the current control's
event procedures. I never thought of it.

God Bless,

Mark
 
Back
Top