Selecting the entire field after setting focus to it

B

BPeters

When setting focus to a field on a form, I'd like the cursor to select the
entire field so it is ready to replace existing data instead of the user
having to double click the field before replacing the data. Thanks.
 
J

Jim Burke in Novi

try this:

txtField.SetFocus
txtField.selStart = 0
txtField.selLength = Len(txtField)
 
K

Klatuu

A good place to do that, Jim is in the GotFocus event of the text box.

Private Sub txtField_GotFocus()
With Me
.txtField.selStart = 0
.txtField.selLength = Len(txtField)
End With
End Sub

(qualify your object references)
 
B

BPeters

Thanks to both of you. I'll give it a try.

Klatuu said:
A good place to do that, Jim is in the GotFocus event of the text box.

Private Sub txtField_GotFocus()
With Me
.txtField.selStart = 0
.txtField.selLength = Len(txtField)
End With
End Sub

(qualify your object references)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top