A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Find label associated with textbox



 
 
Thread Tools Display Modes
  #1  
Old September 6th, 2006, 07:07 PM posted to microsoft.public.access.forms
Herb
external usenet poster
 
Posts: 3
Default 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  
Old September 6th, 2006, 07:19 PM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default 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  
Old September 6th, 2006, 07:23 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old September 6th, 2006, 07:24 PM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 421
Default 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  
Old September 6th, 2006, 08:32 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old September 7th, 2006, 12:01 AM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 421
Default 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  
Old September 7th, 2006, 02:02 AM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default 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  
Old September 7th, 2006, 12:09 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.