Link to home
Start Free TrialLog in
Avatar of wlwebb
wlwebbFlag for United States of America

asked on

Access - Setting Focus on a Textbox and selecting all the text in that textbox

Hello All,

I have an input Form where I validate the number being input in an AfterUpdate to make sure that the amount input is set multiple for the line being input...

That part works... However, in the Exit Event I have an Event that is Supposed to set the focus back to that input field [Amount].  However when I hit Enter on the ok button of the message box that comes up warning that the amount input is invalid, it is moving the focus to the Next field of the form...

I am wanting it to stay in that [Amount] field AND select all the characters input so that when the user starts typing it types over what's already there.  They shouldn't have to backspace or move the cursor to clear the field to startover.

This is what I have.....
Private Sub Amount_Exit(Cancel As Integer)
Dim strDenomination As String
strDenomination = Me.Denomination

    If Me.txtDenomInputProof <> 0 Then
        MsgBox "The amount entered must be a multiple of " & strDenomination & ".  Please review your input and correct.", vbOKOnly
        Cancel = True
        
        Me.Amount.SetFocus
        
    End If

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of irudyk
irudyk
Flag of Canada 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 wlwebb

ASKER

Worked Perfectly!!!!!!!!!!  Thank you!!