How to see a labels associations if any?

D

default105

Is there an easy way to see a labels associations with another object, ie
textbox, combobox?
 
D

Douglas J Steele

Programmatically, you can look at its Parent.

For instance, to find out what control label MyLabel is associated with, you
can use

Forms("MyForm").Controls("MyLabel").Parent.Name

(note that MyForm must be open)

If the label isn't linked to a control, that will return the name of the
form.
 
J

Jeff Boyce

When I want to see if a label is "attached", I open the form/report in
design mode and click on the label. If it is attached, the control to which
it is attached displays a single "handle" in the upper left corner of the
control.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

default105

I know that you can check it that why but what I have noticed by stupidity I
might add is that if you select a label and use ctrl + x and then ctrl+v to
paste it in another section, it is still associatied. However just by
clicking on it, it does not show the handle on the control it is associated
with.
 
D

default105

Do you mean doing this in the immediate window?

Douglas J Steele said:
Programmatically, you can look at its Parent.

For instance, to find out what control label MyLabel is associated with, you
can use

Forms("MyForm").Controls("MyLabel").Parent.Name

(note that MyForm must be open)

If the label isn't linked to a control, that will return the name of the
form.
 
D

default105

Nevermind I see it does work in the immediate window, is there a way to
unassocitate it or do you have to delete it and create a new label, I am
working with mouseover effects and I know the will not work properly if they
are associated.
 
J

Jeff Conrad

J

Jeff Boyce

I don't know why it isn't working for you. When I click on a label control,
if it is attached to another control, that other control's upper left handle
is displayed. If the label control isn't attached, nothing (else) is shown.

Why are you trying to learn to which control a label is attached? Knowing
this might help offer other approaches to solving what you are trying to do.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

default105

I don't know either, because usually what you guys say is golden. Why was I
trying to find the control, because when I would cut the label and paste it,
it did not act as it was associated by clicking on it, using D Steele's
method in the immediate window showed the association was removed but if I
would add a mouse over event to change forecolor, backcolor, etc. It would
not work. Not even if I would compile, compact and repair, quit and
relaunch, decomile, nothing, the event would not work, but if I would create
new label, set all the properties the same as before but not associated to
anything, the mouseover event would work. That is why I was looking to see
if it was associated with anything.

Does that help?
 
J

Jeff Boyce

So, you want to know if a label is attached so you can detach it and
reattach it?

When a form starts "misbehaving" I've been known to set it aside and try
creating a new form. I have no absolute proof, but it seems to me that a
form or a report might get a chicken bone stuck and not be able to tell me
there's something wrong. Starting over and re-creating the form/report
seems to "fix" whatever it was.

Good luck!

Jeff Boyce
Microsoft Office/Access MVP
 
W

Willi Wipp

Hi Folks,

is there any known way of associate an existing label with an existing
textbox via VBA?

Thanks for your support

SL Willi Wipp
 
D

Douglas J. Steele

I don't think so. The Parent property of a control is read-only in all
views, so you can't change it programmatically.

To reassociate a label with a control, you need to cut the label, then paste
it on the control. You could do something like that programmatically (open
the form in Design model, delete the existing label and use CreateControl to
create a new label associated with the control), but I'd question why you'd
ever need to.
 
W

Willi Wipp

Hi Douglas ,

sorry for the late reply. thi swas a question from a forum.
For the question why, I also don't know an answer :eek:)

Thanks for your support

SL Willi Wipp
 
Top