Text Box & Label (1 Viewer)

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
When Adding a text box to a form I sometimes want to adjust it's label individually. I've found cntrl-X - cntrl-V lets me do this
but is a pain if you've just moved it where you want it..
Is there a key combination to do this or some way to (permanently) tell Access to not join controls ?
Thanks.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:01
Joined
Jul 9, 2003
Messages
16,245
This video about Labels and Text Boxes may be of interest.

It shows how to attach an unattached label to a textbox ..

 

Micron

AWF VIP
Local time
Yesterday, 21:01
Joined
Oct 20, 2018
Messages
3,476
Is there a key combination to do this or some way to (permanently) tell Access to not join controls
I think not. I just add the control and usually leave it attached because
a) you can still (usually) place it where you want anyway
b) you can take advantage of the fact that the textbox now has a control in its controls collection. This is quite useful for presenting meaningful user messages e.g. "Please enter a value in Start Date" (the caption of the control's attached label) when validating form fields. Otherwise you're messaging "Please enter a value for txtStartDate" or some such thing.
 

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
I've never found you want the label where Access puts it beside the Text box. So you move it, but the text box moves too. So you move the text box but then the label moves. Then to maker matters worse you give up and decide to delete the label so you can add your own intependant one, and the text box disappears too. All this pain would be gone if Access has a Control-key method to unattach the two.
btw Uncle in your link showed only how to reattach it. He did delete just the label (useful) but never said what he did. If I delete it here, both contosl are gone.
 

June7

AWF VIP
Local time
Yesterday, 17:01
Joined
Mar 9, 2014
Messages
5,423
Are these controls in a layout group? Form design wizards will group controls. I seldom use wizards because they do stuff I don't like.

Associated labels and controls can be moved independently by grabbing control's anchor and dragging. Deleting associated label should not delete textbox. I do it frequently. But I also don't use layout grouping.

Just paste label back and it will be unassociated.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:01
Joined
Oct 29, 2018
Messages
21,358
I've never found you want the label where Access puts it beside the Text box. So you move it, but the text box moves too. So you move the text box but then the label moves. Then to maker matters worse you give up and decide to delete the label so you can add your own intependant one, and the text box disappears too. All this pain would be gone if Access has a Control-key method to unattach the two.
btw Uncle in your link showed only how to reattach it. He did delete just the label (useful) but never said what he did. If I delete it here, both contosl are gone.
Hi. If you're trying to move the label or the textbox independently of each other, make sure you click and drag on the left top corner of the label or the textbox.
 

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
Interesting. The top left corner drag does move them independently, so that's a help. But they're still attached, so deleting one deletes both, and moving one moves both.
There's no layout group, I tested with one text box only.
Cut & Paste remains the only way? But you cannot paste back to the position cut from - it will always go to top left of Detail area?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:01
Joined
Oct 29, 2018
Messages
21,358
Interesting. The top left corner drag does move them independently, so that's a help. But they're still attached, so deleting one deletes both, and moving one moves both.
There's no layout group, I tested with one text box only.
Cut & Paste remains the only way? But you cannot paste back to the position cut from - it will always go to top left of Detail area?
Hi. If you're looking to have independent labels and textboxes, then I guess there is no easy solution for you right now. Textboxes automatically come with labels. Labels don't come with textboxes. So, for example, let's say you want 5 textboxes on your form with 5 separate labels, here's what you could try.
  1. Add one textbox
  2. Select the label and delete it
  3. Select the textbox and copy it
  4. Paste the textbox 4 times
  5. Add a label
  6. Select the label and copy it
  7. Paste the label 4 times
  8. Move all the controls as you like
Now, all you have to do is bind the textboxes and edit the labels.
 

June7

AWF VIP
Local time
Yesterday, 17:01
Joined
Mar 9, 2014
Messages
5,423
Deleting a textbox will take its associated label with it. In my experience, deleting a label has never deleted associated textbox - it stays behind. That's why we are able to cut and paste back associated label so it is no longer associated. I often do this when I want labels as headers in form header section of a continuous form.
 

Micron

AWF VIP
Local time
Yesterday, 21:01
Joined
Oct 20, 2018
Messages
3,476
moving one moves both.
Unless they are members of a layout, I cannot say I've ever experienced this problem. I can only guess that you are clicking on and dragging the wrong part of the label. There are borders for resizing and selection points for moving a control on its own, not as a pair (as long as they are not part of a layout). Sure, Access will likely never place the label where you wish it would. How could it know that you won't need to resize one or the other, so do or do not leave space, or place it on top instead of on the side?? Perhaps not knowing how to move just the label is/was the real reason for your frustration?

If you get used to moving just the label easily, I would suggest you leave them attached. There is not much benefit to un-associating a label but there is reason to leave it associated as I've mentioned. Perhaps you have not yet experienced a situation where that would have been beneficial.
 

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
Thanks for the replies, Yes this all learnt (or not) through trial and error. I swear things act differnenty at times. Now I can delete a label and the text box stays. DBGuy, that all worked fine, once I had the label there. Why does it disappear after you add it until you put some text in it? Then the green triangle and exclamaition dropdown to sort out. I guess it's just how it is and has to be accepted. But I ask in case something buried deep in options can change any of this.
Micron, now I can move them individually by the top left blob, I suppose it doesn't matter about being associated.
Thanks again.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:01
Joined
Oct 29, 2018
Messages
21,358
Thanks for the replies, Yes this all learnt (or not) through trial and error. I swear things act differnenty at times. Now I can delete a label and the text box stays. DBGuy, that all worked fine, once I had the label there. Why does it disappear after you add it until you put some text in it? Then the green triangle and exclamaition dropdown to sort out. I guess it's just how it is and has to be accepted. But I ask in case something buried deep in options can change any of this.
Micron, now I can move them individually by the top left blob, I suppose it doesn't matter about being associated.
Thanks again.
Hi. The sooner you can accept there are certain ways things work as designed in Access, the less "problems" you find you have to worry about. Have fun!
 

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
You're quite right DBguy, but I like to know the why's and hows. For example a text box. You enter a value into it, then read it later in code and it's not that value. Maybe its Null. Use .text and there it is. So later you use .text somewhere else but this time you get an error that it hasn't got the Focus. Well it never had the focus the first time.....
 

Micron

AWF VIP
Local time
Yesterday, 21:01
Joined
Oct 20, 2018
Messages
3,476
That's just part of the learning curve. Sometimes as a responder here, one can remember some of the intricacies; sometimes it requires a test to validate "I think it works this way but I have to check it out". At least you know how to confirm what you think because you know where to start when you have some experience.

You can't get the Text value of a control unless it has the focus is how I recall it. If you didn't have to set it before, it's likely that it already had the focus so you were lucky.
If a textbox is bound it has the OldValue property. If not, it doesn't.
If it hasn't been updated, what you see in it (or can retrieve via code) is not necessarily it's Value property - it may be that what you see is the Text property because it hasn't been updated, and it has no OldValue property because it's not bound. Yikes!

The more you do, the more you learn.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:01
Joined
Mar 14, 2017
Messages
8,738
sometimes things act unexpedtedly in Access it is a learning Process
 

kirkm

Registered User.
Local time
Today, 14:01
Joined
Oct 30, 2008
Messages
1,257
Fair enough. LOL I should have learnt more by now :)
How would you do this?
You have 2 textboxes and an image control. The image code needs to know what (if anything) is in either textbox.
In the Click event for both I set the other to "". In theory that prevents them both having a value.
Then in the Image code I get this problem about focus. Neither textbox should have Focus as I've just clicked the Image control. But its not so.
There didn't seem to be any Lose Focus or Lost Focus options for text boxes.
So I had to add anotehr text box and set its Focus. Then everything works. But isn't that a hack ?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:01
Joined
Oct 29, 2018
Messages
21,358
You're quite right DBguy, but I like to know the why's and hows. For example a text box. You enter a value into it, then read it later in code and it's not that value. Maybe its Null. Use .text and there it is. So later you use .text somewhere else but this time you get an error that it hasn't got the Focus. Well it never had the focus the first time.....
Hi. Just a quick note about the difference between Text and Value. If you go the linked article I provided below, you will this quoted part.
While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control.
 

Micron

AWF VIP
Local time
Yesterday, 21:01
Joined
Oct 20, 2018
Messages
3,476
In the Click event for both I set the other to "". In theory that prevents them both having a value.
No, one has a value of "" (zero length string) and you can retrieve that content. I don't completely follow your explanation so don't know what to say about it except that a textbox must have the focus to get its Text property. Apparently, an image control has a set focus method but when I tried to use it, it failed. It has no enabled property or OnGotFocus event either, so maybe when you think the image control has the focus, it does not.
 

June7

AWF VIP
Local time
Yesterday, 17:01
Joined
Mar 9, 2014
Messages
5,423
Apparently image control cannot take focus. I tested its Click event. Event fires but textbox retains focus.
 

Users who are viewing this thread

Top Bottom