How to tell what textbox got the focus
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 |
How to tell what textbox got the focus
vqthomf:
try ? r = Len(TextBox1.Text) TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = r TextBox1.Paste -- 天行健,君*以自強不息 地勢坤,君*以厚德載物 http://www.vba.com.tw/plog/ "vqthomf" wrote: 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 |
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 |
All times are GMT +1. The time now is 02:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com