If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Find label associated with textbox
Is there a way, in code, to determine the label that is associated with a
specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb |
#2
|
|||
|
|||
Find label associated with textbox
Herb wrote:
Is there a way, in code, to determine the label that is associated with a specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb Each control with an attached label actaully has its own Controls collection with the label being the first member. So... Me.TextBoxName.Controls(0) ....should give a reference to the label attached to TextBoxName. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#3
|
|||
|
|||
Find label associated with textbox
It's actually easier to do the reverse: if a label is linked to a specific
control, then Forms("NameOfForm").Controls("NameOfLabel").Parent .Name will return the name of that control, whereas it will return the name of the form is the label isn't linked to a control. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Herb" wrote in message ... Is there a way, in code, to determine the label that is associated with a specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb |
#4
|
|||
|
|||
Find label associated with textbox
This is usually done using the label's Tag property.
If a label were associated with a text control called City, it could be given a Tag of "City" Then you're control loop could look for that value... -- hth Al Campagna Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "Herb" wrote in message ... Is there a way, in code, to determine the label that is associated with a specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb |
#5
|
|||
|
|||
Find label associated with textbox
"Rick Brandt" wrote in message
t... Herb wrote: Is there a way, in code, to determine the label that is associated with a specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb Each control with an attached label actaully has its own Controls collection with the label being the first member. So... Me.TextBoxName.Controls(0) ...should give a reference to the label attached to TextBoxName. I knew it was something like that, but my mind went blank when answering! -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
#6
|
|||
|
|||
Find label associated with textbox
Rick,
Never knew that. Always learning something here... Al Campagna "Rick Brandt" wrote in message t... Herb wrote: Is there a way, in code, to determine the label that is associated with a specific text box, checkbox, combo box, etc.? The idea would be to loop through the controls in a form and be able to identify the label that is associated with one of these controls. Thanks for any help on this, Herb Each control with an attached label actaully has its own Controls collection with the label being the first member. So... Me.TextBoxName.Controls(0) ...should give a reference to the label attached to TextBoxName. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#7
|
|||
|
|||
Find label associated with textbox
Al Campagna wrote:
Rick, Never knew that. Always learning something here... Al Campagna Hey, I just learned it myself in these groups a few months ago :-) -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#8
|
|||
|
|||
Find label associated with textbox
"Rick Brandt" wrote in message
... Al Campagna wrote: Rick, Never knew that. Always learning something here... Al Campagna Hey, I just learned it myself in these groups a few months ago :-) The sad part is it might of been me you learned it from! g -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
Thread Tools | |
Display Modes | |
|
|