Thread: [Solved] Find textbox name
View Single Post
 
Old 01-31-2014, 07:22 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

IF you want the textbox to return its name when you click in it use:

Private Sub Document_City_Enter()
MsgBox Me.Document_City.Name
End Sub

as previously provided, or

Private Sub Document_City_Enter()
MsgBox Me.ActiveConrol.Name
End Sub

as Paul provides, or

If you click a command button Document_City obviously no longer has the focus so:

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

Naturally returns cmdTextBoxName, because cmdTextBoxName is now the active control.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote