View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to tell what textbox got the focus

Try this:

Private Sub CommandButton1_Click()
MsgBox Me.ActiveControl.Name
End Sub

so ActiveControl returns a reference to the selected control (textbox).
However, you must change the TakeFocusOnClick property of the commandbutton
to False otherwise ActionControl will refer to the commandbutton itself.

--
Regards,
Tom Ogilvy


"vqthomf" wrote in message
...
Hi I have a form with two textboxes and a button that I want to use to

paste
into the textboxes for another source, I have tried to use gotfocus with

the
textbox but I can't get it to work can someone please show how I can do

this
thanks.
TIA
Charles