Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    controls labels on form (2003)

    Is it possible to capture the identity of a label attached to a list box, combo box, etc?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: controls labels on form (2003)

    Can you explain in more detail what you want to accomplish? Thank you.

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    Re: controls labels on form (2003)

    I have two clients who are providing a national health program. Since it's a public health program they have each appended local elements to the program and want to be able to track them. When there were only two clients I just had two separate programs but both of my clients were singing my praises at a conference and now I've had several other queries. Writing two programs was the lazy way out but more than would soon become a nightmare.
    What I hope to accomplish is a table driven form for collecting the local data so that the client could specify which elements were to be collected and the order in which they appear. The information is to be entered into either text or combo boxes so enabling or setting the tab order seems simple enough but some of the clients get very picky about how the questions are labeled. It would be nice to be able to offer an editable label as a local variation.
    Perhaps using the information and building a new form would be better than trying to edit an existing one. In either case I'll still need to access the value of the attached label.
    Does that explanation help or just make it worse?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: controls labels on form (2003)

    I'd name the editable controls (text boxes, combo boxes) and labels in such a way that you know which ones belong together, for example txtLastName and lblLastName, or cboCompany and lblCompany.

    If that is not feasible, you can look at the Parent property of a label to find out which control it belongs to. Sample code:

    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.Parent.Name = "txtLastName" Then
    MsgBox ctl.Name
    Exit For
    End If
    Next ctl

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    Re: controls labels on form (2003)

    I think your suggestion of the naming convention will be the most practical approach. Thank you for sharing your thoughts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •