Which control has focus?

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
 
S

Steve C

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
 
D

Douglas J. Steele

Screen.ActiveControl returns a reference to the actual control:
Screen.ActiveControl.Name will return its name.
 
M

Marshall Barton

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
 
M

Mark A. Sam

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
 

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

Top