Default300
Board Regular
- Joined
- Jul 13, 2009
- Messages
- 83
Is there a Keyword (such as "Me" or "Parent" etc.) that I could use to Return the Name Property of a Control from within that Control's Event Code.
For example:
I am hoping that if this were possible, I could make code blocks more generic and reuse them for several controls, whether in separate Subs or Looping through Object Collections, or Grouped Controls.
I would only want to do this within the event code of the control whose name I want to use.
If there's a quick answer to the question, great!
If not then, besides the simulated example given above, I cannot give more details on what I (would be) trying to achieve. At the moment, I don't have a real world example for people to advise me on workarounds. If there's no obvious answer, then I'll give details / reask the question next time a concrete example of the issue arises.
Thanks.
For example:
Code:
[FONT=Courier New]Private Sub cboComboBox1_Change()
Dim strControlNameCurrent As String
Dim strControlNameOther As String
[COLOR=SeaGreen]'With [/COLOR][COLOR=Red]?MeMyself_ieControlObject_NotUserForm[/COLOR]
strControlName[/FONT][FONT=Courier New]Current[/FONT][FONT=Courier New] = .Name
[COLOR=SeaGreen]'aim is for above line to return "cboComboBox1"[/COLOR]
strControlNameOther = "lbl" & Mid(strControlName, 4, Len(strControlName - 3))
strControlNameOther.BackColor = 3
[COLOR=SeaGreen]'End With[/COLOR]
End Sub[/FONT][FONT=Courier New]
[/FONT]
I would only want to do this within the event code of the control whose name I want to use.
If there's a quick answer to the question, great!
If not then, besides the simulated example given above, I cannot give more details on what I (would be) trying to achieve. At the moment, I don't have a real world example for people to advise me on workarounds. If there's no obvious answer, then I'll give details / reask the question next time a concrete example of the issue arises.
Thanks.