Textbox label association

  • Thread starter Thread starter Gregory La Due
  • Start date Start date
G

Gregory La Due

Is there any way to determine, programmatically, which label is associated
to a another control?

Gregory La Due
Twin Tiers Technologies, Inc.
 
A label control may be a child of a text box. For instance if your text box
is named txtFirstName, the associated labels caption might be

Forms!Employees!txtFirstName.Controls(0).caption
 
You can loop through all of the labels, and check what the parent is.

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is Label Then
If ctlCurr.Parent.Name = "MyDesiredControl" Then
MsgBox "Label " & ctlCurr.Name & " is associated with
MyDesiredControl"
Exit For
End If
End If
Next ctlCurr
 
Back
Top