Reference a field labels caption?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rico

    #1

    Reference a field labels caption?

    Hello,

    I'm looping through controls on a form, focusing on text boxes. If the field
    is null and I'd like to throw a pop up letting the user know that this
    "required" textbox is not filled out. If I show the user
    "control.contro lname" then I get the txtThisIsMyFiel d and it doesn't help
    the user much. I'd like to reference caption of the fields bound label. Is
    there any way of doing that?

    Thanks!


  • RoyVidar

    #2
    Re: Reference a field labels caption?

    Rico wrote in message <Yc9Af.409363$k i.298102@pd7tw2 no> :[color=blue]
    > Hello,
    >
    > I'm looping through controls on a form, focusing on text boxes. If the field
    > is null and I'd like to throw a pop up letting the user know that this
    > "required" textbox is not filled out. If I show the user
    > "control.contro lname" then I get the txtThisIsMyFiel d and it doesn't help the
    > user much. I'd like to reference caption of the fields bound label. Is
    > there any way of doing that?
    >
    > Thanks![/color]

    To reach the caption of an attached label, try some of the following
    air code

    for each ctl in me.controls
    if <some condition> then
    if ctl.controls.co unt > 0 then
    ' to ensure there is an attached label
    msgbox ctl.controls(0) .caption
    else
    msgbox ctl.name
    end if
    end if
    next ctl

    --
    Roy-Vidar


    Comment

    • Allen Browne

      #3
      Re: Reference a field labels caption?

      If the control has an attached label, you can read its caption as:
      ctl.Controls(0) .Caption

      --
      Allen Browne - Microsoft MVP. Perth, Western Australia.
      Tips for Access users - http://allenbrowne.com/tips.html
      Reply to group, rather than allenbrowne at mvps dot org.

      "Rico" <r c o l l e n s @ h e m m i n g w a y . c o mREMOVE THIS PART IN
      CAPS> wrote in message
      news:Yc9Af.4093 63$ki.298102@pd 7tw2no...[color=blue]
      > Hello,
      >
      > I'm looping through controls on a form, focusing on text boxes. If the
      > field is null and I'd like to throw a pop up letting the user know that
      > this "required" textbox is not filled out. If I show the user
      > "control.contro lname" then I get the txtThisIsMyFiel d and it doesn't help
      > the user much. I'd like to reference caption of the fields bound label.
      > Is there any way of doing that?[/color]


      Comment

      Working...