Is there a benefit to having the label and text box connected
outside of when you move the text box - the label box moves with
it and it also helps with keeping things organized. This is fine
if this is its purpose, just wondered if there is something else
I'm not noticing.
For one, an attached label can be referred to through the Controls
collection of the control it's attached to:
Me!txtMyTextBox.Controls(0).Caption = "Some text"
You can then set properties for that label without needing to know
its actual name. Likewise, if you're doing something like this to
set up a form's controls:
Dim ctl As Control
For Each ctl in Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox, acListBox
If ctl.Controls.Count > 0 And IsNull(ctl) Then
ctl.Controls(0).ForeColor = 255
End If
End Select
Next ctl
Set ctl = Nothing
This would set the labels of all controls without a value to RED.
That's just an example of where attached labels are useful. Also, if
you disable a control with an attached label, the label gets the
"disabled" look, too.
I think that in general, non-attached labels should be the exception
rather than the rule, at least for labels that describe a control.
There are certainly plenty of needs for unattached labels, and in
those cases, it would be nice if after a certain point in a form's
life, you could turn off the error reporting of unattached labels.
But it's a pretty minor annoyance overall.