• controls labels on form (2003)

    Author
    Topic
    #449090

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

    Viewing 0 reply threads
    Author
    Replies
    • #1100062

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

      • #1100163

        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?

        • #1100191

          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

          • #1100210

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

    Viewing 0 reply threads
    Reply To: controls labels on form (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: