Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Howto select whole field on doubleclick?

Posted on 2003-03-07
Medium Priority
Last Modified: 2010-08-05
Double clicking a text box in Access only selects (highlights) the portion of the text that is contained between special characters like spaces, commas etc. I need it to select the whole text.

I tried something like the following:

'-- Start code
Public Sub SelectWholeField()
    Dim ctl As Control, str As String
    Set ctl = Screen.ActiveControl
    Select Case ctl.Value
        Case Null
            Exit Sub
        Case Else
            str = ctl.Text
            ctl.SelStart = 0
            ctl.SelLength = Len(str)
    End Select
End Sub

However it works only on the OnClick event. When used on OnDoubleClick it still behaves as if there is no code.

Any ideas how to get the whole field selected when double clicking?

Question by:Edouard
LVL 41

Accepted Solution

shanesuebsahakarn earned 1000 total points
ID: 8093722
When you call the code, add a CancelEvent line as well:

Private Sub MyTextBox_DblClick(Cancel As Integer)
End Sub

That should do it for you.

Author Comment

ID: 8094724
Excellent! Thanks a lot.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question