Highlighting a field

  • Thread starter Thread starter Andy Millar
  • Start date Start date
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
 
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)
 
Try this

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

Madhivanan
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top