Hightlight text in text box on entering (1 Viewer)

George-Bowyer

Registered User.
Local time
Today, 16:18
Joined
Dec 21, 2012
Messages
177
I don't know the technical terms for what I'm asking for here, which is impeding my success on google.

One of the main forms on my db is a search form with a listbox, which is filtered by typing text into a text box. Users can then double-click on a record in the list box to open their details.

I want to set it so that if the user clicks back into the text box, if there is any text in it, it is automatically highlighted and can be deleted with one keystroke. I don't want to set the value to null, though.

Sometimes when I am using it, this happens anyway, and sometimes it doesn't and I haven't been able to work out why, yet?

Thanks,

George
 

George-Bowyer

Registered User.
Local time
Today, 16:18
Joined
Dec 21, 2012
Messages
177
This code did it:
Code:
    If Not IsNull(txtSearch) Then
    
        txtSearch.SelStart = 0
        txtSearch.SelLength = Len(txtSearch.Text)
        
    End If

However, it has to go in the "On click" event, not the "Got Focus" event, which took some finding.
 

Users who are viewing this thread

Top Bottom