Input mask question

snicker

Registered User.
Local time
Today, 03:03
Joined
Aug 8, 2003
Messages
91
I have a text box has an input mask for a phone number. I want to bring the cursur to the begining of the text on the "on enter" event.
I am using:
Code:
Private Sub FaxNumber_Enter()
On Error GoTo Err_FaxNumber_Enter

SendKeys "{F2}", True

Exit_FaxNumber_Enter:
    Exit Sub

Err_FaxNumber_Enter:
    MsgBox Err.Description
    Resume Exit_FaxNumber_Enter
End Sub

This doesnt work. If I put this code on the "on click" event it works fine but it prevents the user from being able to position the cursor with the Mouse for that control. Can anyone tell me why or help with a solution?

thx in advance
Mike
 
Actually, for this you will want to use the text box's GotFocus event. Try this code:
Code:
Private Sub FaxNumber_GotFocus()
On Error GoTo Err_FaxNumber_GotFocus

SendKeys "{F2}", True

Exit_FaxNumber_GotFocus:
    Exit Sub

Err_FaxNumber_GotFocus:
    MsgBox Err.Description
    Resume Exit_FaxNumber_GotFocus
End Sub
 

Users who are viewing this thread

Back
Top Bottom