How can I get Access to stop selecting all the text in a text box??? (1 Viewer)

Myrna Larson

Registered User.
Local time
Today, 13:22
Joined
Aug 3, 2012
Messages
16
The global Client setting for "Behavior Entering Field", may not always be maintained.

Ain't THAT the truth !!! :mad::mad:

You probably noticed that I have code in the Enter event, not only for this text box but for several others, which sets the selection start to 0 and length to 0. Access only started misbehaving for this one text box after I moved it from the main form to the 2nd page of the new tab control. The text boxes on the 1st page of the tab control have similar code and work fine.

Should I call your procedure from the Enter event procedure or somewhere else?
 

AccessNubie

New member
Local time
Today, 13:22
Joined
Aug 10, 2012
Messages
4
I'm a brand new Access user... so take what i say with a lot of skepticism. If i understand your problem, try this (i'm using Access 2010).
Go to File > Options > Client Settings > Behavior Entering Field and set to 'Go to Start of Field.
 

Myrna Larson

Registered User.
Local time
Today, 13:22
Joined
Aug 3, 2012
Messages
16
Thanks for jumping in. This has gotten to be a long thread, but if you look at my very first post you'll see this: "The Client Setting for behavior on entering field is go to start of field. That should eliminate my problem, but it doesn't." And in message #16 I said "The Client settings are to put an insertion point at the start of the field when a control is entered."

That that's in fact what happens in all the other text boxes. It just doesn't happen in this one that resides by itself on the 2nd page of a Tab Control. Thanks for trying to help.
 

Alan White

New member
Local time
Today, 11:22
Joined
Aug 10, 2012
Messages
5
Myrna,
Thank you for you reply.
I have shared in your frustrations trying to provide a good user interface. Persistance has its own reward. I am not sure if you have solved your problem yet.

Private Sub Notes_Enter()
'Notes is the only control on the 2nd tab, i.e. Page 1
With Me.Notes
.SelStart = 0
.SelLength = 0
End With
Application.SetOption "Behavior Entering Field", 1 ' 1 = Start 2= End 0 = all
End Sub

I believe this should work.
Please let me know if it does...
Regards,
Alan
 

Myrna Larson

Registered User.
Local time
Today, 13:22
Joined
Aug 3, 2012
Messages
16
Sorry, but no, this didn't work. I'm not sure it should. You added the line to the Notes_Enter event sub. I believe (but am not sure) that this code runs AFTER the field has been entered, at which point the selection has already been made.

FWIW, in playing around with this, I created 2 more event procedures: (1) DoHip_LostFocus (that's the last field on the 1st page of the Tab Control), which sets focus to the Notes control and tries to set Notes' selection start and length, and (2) Notes_GotFocus, which also set selection start and length. Neither of these worked.

So I put break points in the code to see in what order the procedures ran, and I found that Notes_GotFocus ran BEFORE DoHip_LostFocus.

That seems strange to me, but perhaps there's no way to know one control has lost focus until you get the signal that a different control has received it. Since the sequence in which the code ran was consistent, I removed from DoHip_LostFocus the lines that set selection start and length -- Notes_Enter had already executed those instructions. But I had to retain the line that sets focus to Notes. Without it, tabbing out of DoHip moves to the next record!!

Another FWIW: if from the last text box on page 1 (DoHip) I press CONTROL+TAB to move to the 1st control on the 2nd tab (Notes), the selection is correct -- just an insertion point at the beginning.

Thanks for your input. BTW, if you download the sterilized file attached to a previous message, you also can try your code. Maybe you can get it to work.

At this point, I can only conclude that this is a bug. Oh, sorry, an issue.
 

threni

New member
Local time
Today, 14:22
Joined
Aug 18, 2010
Messages
5
I wonder if this issue has been resolved. it's awfully easy to delete a whole field of text when it is automatically selected.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:22
Joined
Oct 29, 2018
Messages
21,453
I wonder if this issue has been resolved. it's awfully easy to delete a whole field of text when it is automatically selected.
Hi. There could be something wrong with the OP's file, which I didn't try, by the way, but when I did the following on my own ACCDB file, it worked as advertised. Have you tried it and still having problems with it? Or did you have a different problem altogether?


 

Attachments

  • edit.PNG
    edit.PNG
    31.5 KB · Views: 346

Gasman

Enthusiastic Amateur
Local time
Today, 19:22
Joined
Sep 21, 2011
Messages
14,231
I wonder if this issue has been resolved. it's awfully easy to delete a whole field of text when it is automatically selected.

It has been over 7 years, chances are that it has. D
 

threni

New member
Local time
Today, 14:22
Joined
Aug 18, 2010
Messages
5
Maybe it has been solved, maybe not. I am aware of the length of time that has elapsed since the posting. Thanks to the dbGuy for offering a solution.
 

Users who are viewing this thread

Top Bottom