Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2014, 07:15 AM
Hdata Hdata is offline Find textbox name Windows 7 32bit Find textbox name Office 2010 32bit
Novice
Find textbox name
 
Join Date: Jan 2014
Posts: 26
Hdata is on a distinguished road
Default

I created a command button on the userform and attached the code below:

Code:
 
Private Sub cmdTextBoxName_Enter()
MsgBox Me.ActiveControl.Name
End Sub
What I received back was


"cmdTextBoxName"

The name of the textbox is actually "Document_City"
What am I missing?
Thank you for your response

Hdata
Reply With Quote
  #2  
Old 01-31-2014, 03:11 PM
macropod's Avatar
macropod macropod is offline Find textbox name Windows 7 32bit Find textbox name Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Hdata View Post
I created a command button on the userform and attached the code below:

Code:
Private Sub cmdTextBoxName_Enter()
MsgBox Me.ActiveControl.Name
End Sub
What I received back was
"cmdTextBoxName"

The name of the textbox is actually "Document_City"
What am I missing?
Well, your sub's name (cmdTextBoxName_Enter) shows that the control's name can only be 'cmdTextBoxName'. Evidently, you want something else; perhaps the name of a visually-related label. If so, unless the label and control are grouped (and nothing else is in the same group), there is no 100% reliable way for VBA to identify which one you want.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
clip art with embeded textbox Mel Spence Misc 0 05-19-2013 09:38 AM
Find textbox name Display result in textbox based on the input of another textbox scarymovie Word VBA 5 05-16-2012 07:05 PM
textbox color issue Dave Duncan Word 0 08-07-2011 10:38 AM
Textbox Template t0m46 Word 0 09-07-2010 03:38 AM
Creating Chart using VB textbox value shyler82 Word VBA 0 03-12-2010 06:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft