How to determine what a control's attached label is

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

This seems like it should be easy, but I just don't see it. I'm trying to
write an automatic form validator in Access XP. All required controls on a
form have a certain background color. In the form's BeforeUpdate routine, I
loop through all of the controls on the form, and, if I find a required
control that is null, I then want to pop up a message box which shows the
caption of the attached label as part of the error message. But I can't see
how to programmatically determine which labels are attached to which
controls. I've looked through help and I've looked through all of the
properties of both labels and textboxes/comboboxes at run time and there's
no love there. I realize that I could manually force this, either by naming
the labels appropriately, or putting the name of the attached label in the
textbox/combobox tag property, but this seems both onerus and unnecessary.

Am I missing something, and if so, what?

Thanks, Jim
 
If a control has an attached label, it is the first (and only) member of the
control's Controls collection:
ctl.Controls(0)
 
Back
Top