How to know which label is attached to a control

  • Thread starter Thread starter Carl Willems
  • Start date Start date
C

Carl Willems

Hi,

I have this form with several text controls, each with an attached label in
front. Now I need the control and the label to have a certain formatting,
depending on the value in the control. Today I use the event of each control
to trigger the formatting and I place in the code the exact name of the
label, which means that I have to copy lots of code over and over again,
adjusting label names depending on the control, with typing errors... I
would rather like to use code that evaluates each control, and will change
the formatting of the control along with the attached label. Only: how do I
know which label is attached to which control ? A control doesn't seem to
have a property that indicates the attached label, nor has the label such a
property. Any clues ?

thanks,
Carl
 
Carl,

You can access a data control's attached label by way of its Controls
property. For example, if you have a textbox named MyTextbox, with an
attached label, you can manipulate the font of the label by...
Me.MyTextbox.Controls(0).FontName

Similarly, you can access the textbox via the Parent property of the label.
 
Back
Top