View Full Version : Select All text


halem2
04-12-2007, 05:37 AM
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

ted.martin
04-12-2007, 06:12 AM
Is docmd.setfocus what you need?

halem2
04-12-2007, 06:18 AM
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
04-12-2007, 06:29 AM
Once the textbox has the focus the text is surely highlighted. It certainly works with the Ctl+C keywboard stroke.

PeterF
04-12-2007, 07:29 AM
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:
application.setOption "Behavior Entering Field", 0

halem2
04-12-2007, 07:44 AM
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
04-12-2007, 07:47 AM
Sure, an easy way is to put this in the GotFocus event:

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

halem2
04-12-2007, 07:53 AM
That's exactly what I needed.

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