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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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