When working with data entry
controls, the current value in the
control often needs to be selected when
the control received focus. This allows
the user to immediately begin typing over
any previous value. Here's a quick
subroutine to do just that:
Code
Public Sub SelectAll(Editctr As
Control)
With Editctr
.SelStart =
0
.SelLength
= Len(Editctr.Text)
.SetFocus
End With
End Sub
Use
If
the GotFocus event of an input control,
put the following code:
Call SelectAll(controlname)
For
example, if the input control was called
txtHello, the code in its GotFocus event
would be:
Call SelectAll(txtHello)
|