Determine which control was clicked by user

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?
 
F

fredg

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.
 
S

Steve

--
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.
 

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