Determine which control was clicked by user

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Greetings:

I have 10 unbound textbox controls and a command button. The user will click
a text box and then the command button. I would like to be able to identify
the last textbox clicked by the user before he/she clicks the command button
without writing a separate procedure for each textbox. Is this possible?
 
Greetings:

I have 10 unbound textbox controls and a command button. The user will click
a text box and then the command button. I would like to be able to identify
the last textbox clicked by the user before he/she clicks the command button
without writing a separate procedure for each textbox. Is this possible?

In the command button's Click event:

MsgBox Screen.PreviousControl.Name

will return the name of the control in a message box.

MsgBox Screen.PreviousControl

will return the value of the previous control.
 
--
Steve


fredg said:
In the command button's Click event:

MsgBox Screen.PreviousControl.Name

will return the name of the control in a message box.

MsgBox Screen.PreviousControl

will return the value of the previous control.

Great! Thanks.
 
Back
Top