Highlighting a field

A

Andy Millar

Hi
I know how to set the options so that the whole field is highlighted
when I tab into a text box.
Is there any way to do the same thing when you click into a box?
Any help appreciated! - Andrew Millar
 
D

Dennis

Providing there is something in the box when you click into it, you can put
this code in the On got Focus event for the box. If it could be Null or an
empty string then you may have to check for this with an If statement before
using this line of code

YourBox.SelLength = Len(YourBox)
 
M

Madhivanan

Try this

Private Sub Text0_Click()
Text0.SelStart = 0
Text0.SelLength = Len(Text0.Text)
End Sub

Madhivanan
 
A

Andy Millar

Tried them both, and the winner is......
Madhivanan!

The text box I need to do this with is formatted to currency with
default 0. Using your method Dennis, I only get the £ symbol in £0.00
highlighted. With Madhivanan's I get the whole thing highlighted.
(perhaps its because its currency?)

This is very handy - users can click to a box and enter a new currency
amount without having to drag over the £0.00 to highlightit first.

Thanks to BOTH of you!
Andy
 
Top