Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Double-click a field that has a currency number in it and select the entire field

A few days ago an expert provided a solution so that if I double-click in a text box, the entire contents of the text box get highlighted, not just the work I d/c on.  Here is the code as provided:

Private Sub txtName_KeyPress(KeyAscii As Integer)
On Error GoTo Err_txtSymbol_KeyPress

    Const vbKeyNone As Integer = 0

    If KeyAscii = vbKeySpace Then
        KeyAscii = vbKeyNone
        DoCmd.Beep
    End If

    If Trim(Replace(Me!txtName.Text, "_", "")) = "" Then
        Me!txtName.SelStart = 0
    End If

Exit_txtName_KeyPress:
    Exit Sub

Err_txtName_KeyPress:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
    Resume Exit_txtName_KeyPress
    
End Sub

Open in new window


However, I just discovered that if I d/c on the field and it is a currency field, it does not highlight the entire field.  How can I fix this so it does highlight the entire field?
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

When I d/c the original text field, the entire string of characters gets selected.  When I d/c a currency field I want the entire string of numbers including the decimal to be selected.
That's what it does here.
After a double-click:

User generated image
You are absolutely correct.  I was confused.
Oh.
Have a nice weekend!