Select All text (1 Viewer)

halem2

Registered User.
Local time
Today, 15:05
Joined
Nov 8, 2006
Messages
180
hello World!


Running Access 2000.

I have a form with one text box in it. How can I select all the text in the txt box when the form opens and when I move to next record?

thanks you
 

halem2

Registered User.
Local time
Today, 15:05
Joined
Nov 8, 2006
Messages
180
not really. The txt box is the only control in the form so it has the focus already. What I need is to to have the text inside the txt box all selected, as if you were going to copy it.
 

ted.martin

Registered User.
Local time
Today, 19:05
Joined
Sep 24, 2004
Messages
743
Once the textbox has the focus the text is surely highlighted. It certainly works with the Ctl+C keywboard stroke.
 

PeterF

Registered User.
Local time
Today, 21:05
Joined
Jun 6, 2006
Messages
295
Once the textbox has the focus the text is surely highlighted. It certainly works with the Ctl+C keywboard stroke.

This behaviour depends on the setting under Extra > Options > tab Keyboard: "Behavior Entering Field" (Hope I guessed the menu option right).
This is a user setting and can be controlled in VBA by:
Code:
application.setOption "Behavior Entering Field", 0
 

halem2

Registered User.
Local time
Today, 15:05
Joined
Nov 8, 2006
Messages
180
Thanks guys for the help.

Peter: is the a way to change the behavior to Entire Field in just one control in a specific form, while leaving the Options to Beginning of Field?
 

boblarson

Smeghead
Local time
Today, 12:05
Joined
Jan 12, 2001
Messages
32,059
Sure, an easy way is to put this in the GotFocus event:

Me.YourTextBoxName.SelStart=0
Me.YourTextBoxName.SelLength = Len(Me.YourTextBoxName.Text)
 

halem2

Registered User.
Local time
Today, 15:05
Joined
Nov 8, 2006
Messages
180
That's exactly what I needed.

Thanks to Everyone involved. Bob, as usual, you're right on the money!. thanks :D
 

David S

Registered User.
Local time
Today, 20:05
Joined
Jan 6, 2012
Messages
11
Bob. Am new to this! Did you mean "put in the OnClick event" not GotFocus?

I can get it to work on the onclick but not gotfocus. Am I missing some point here? I know default action on using Tab to enter a field is to select all the text and this property can be changed [see PeterF - above]. But my problem was to get the whole field/text selected when clicking with a mouse, which your code fixes [using onclick]. Thanks David
 

Users who are viewing this thread

Top Bottom