linking labels to controls

Eljefegeneo

Still trying to learn
Local time
Today, 14:48
Joined
Jan 10, 2011
Messages
899
I have come across a problem, mostly of my doing, in that I cannot link a label with a control. I don't know how it happens, or rather how I do it, but on various forms the label is not linked to the proper control. I try to do it by clicking on the warning popup on the right side and indicate I want to associate the label with the control, but sometimes it just doesn't work. That is, if I set the visibility of the control to True or False depending on the value of another control, the label still appears.
I've looked in the properties of each, but there doesn't seem to be anything there to indicate the link or association. Other than laboriously copying and pasting the label back on the form with the control highlighted, is there any way else to do this?
 
I don't know your situation of course without seeing anything. Can you post your code to set the visibility? Is the Label the original one created with the Control?
 
Thank you for your reply. The code used is merely if one text box or combo box has a certain value, then one or more controls and their labels are either visible or invisible. In the particular case which was giving me problems, if [Country] = "USA", then the [State] and [Zip4] controls would be visible. If [Country] = "CANADA" then the [State] and [Zip4] codes would be not visible and the [CanadaProvince] and [PostalCode} would be visible. I was in the habit of listing both the control and the label for .visible = T/F:
If [Country] = "CANADA"
State.Visible = False
lblState.Visible = False
CanadaProvince.Visible = True
lblCanadaProvince.Visible = True

But then someone politely informed me that I didn't need to do this, that the lblState.Visible= False was not necessary. At which point I discovered that my labels and controls were sometimes not associated. But when I attempted to associate them, the code won't work unless I have both the control and the label listed.

I know that if you highlight a control and its label and they are not associated, then a warning appears on the lower right hand side at which time I can select that I want to associate the label with the control. But sometimes it doesn't which forces me to either delete the control and add it back again, or cut and paste it back. Seemingly not a hard thing to do, but I have a lot of forms and controls where this would be necessary.
So I was trying to determine if there was another was to make sure that a control and its label were indeed associated so that I would not have to make my code more complex by always adding the lblControlName in my code.
There doesn't seem to be any way of checking this is the properties box. I can only truly discover it by testing the code and determining if a label is acting like it is associated with its proper control.
I realize that this is not a big deal, but it just adds to my confusion and frustration when I try to write code in the correct manner.
Any hints and suggestions would be appreciated. And yes, I will be more careful in labeling controls int he future.
 
Why would you have a lot of broken labels to controls anyway? Suggest you do this manually or else go thru the trouble of re-creating the actual controls on the form. I suppose you could write a module for this but I would no know how.

Test with your code as you say and fix.

Good Luck!
 
That is the big question. Do not know how it happened, but there you go. Bad design leads to future problems. Was hoping there was an 'easy' solution, but now I am going to pay the piper - go through all the forms and check them. A lesson learned the hard way! Thanks for answering.
 
To manually reassociate a label with a control do the following:

1. Delete the label by selecting it and using ctrl-x
2. Select the control you want to associate the label to
3. Paste the label by using ctrl-v

alternatively in VBA you can assocate a label to a control by using the following:

me.txtbox.controls(0)=me.label

change 'txtbox' and 'label' to the names of the respective control and label
 
That is what I thought. Delete and Paste. As I said in my previous post, if anything I have brought to the attention of others to make sure they do not repeat my mistake. I must have gotten too cute in making the forms and didn't properly associate the labels with the controls.
 
I have a feeling that I must be doing something very simple yet wrong. I have tried to cut and then paste but it won't work. The module is in USPS2. The controls are visible/invisible as per the code in the module, but no matter what I do I cannot associate the ones for ForeignTelephone, AltForeignTel and ForeignFax.

So I am attaching a sample of the DB again. Thanks for spending time on this.
 

Attachments

So far as I can see they are associated. I'm not clear what you mean by the code in the module won't work.

The only thing I have noticed is that the label visibility should be set to true - if the associated control is set to false, the label won't show, but if the label visibilty is set to false and the associated control is set to true, it still won't show
 
I just knew it was something really simple. Somehow the field visibility of the label was set to false. I didn't do it, but it was. Changed it and Voila! Now the field label is visible is the associated field is visible. I guess these are the things that drive people nuts like it was doing to me. Thanks once again.
 
Try:

Arrange > Tabular and then if necessary Remove or Stack. The later makes a mess but generally I have found the association is impossible if the label is on the header and the control in the detail section.

Simon
 
Simon, not sure what you are saying. The control and label ar on the same part as the form. Could you please explain. Thanks.
 

Users who are viewing this thread

Back
Top Bottom