move cursor to front of field

  • Thread starter Thread starter Jesper F
  • Start date Start date
J

Jesper F

I use date fields with input masks, but if the cursor is
placed in the middle of the field insted of the front the
users sometimes get confused.
Can the cursor be placed at the front of the field
programatically upon entering the field?
 
In a standard module, add the following function

Public Function MoveStart()

'v 2/24/04
Dim ctL As Control

On Error Resume Next

Set ctL = Screen.ActiveControl
If IsNull(ctL) Then
ctL.SelStart = 0
End If

Set ctL = Nothing
End Function

In the mouseup and onenter events of the textbox with the input mask put
=MoveStart().

This will move the cursor to the beginning of the textbox if is is empty.
 
Back
Top