select entire text in textbox

select entire text in textbox

Post by Keith G Hi » Sun, 08 Mar 2009 03:36:51


(A2003)

I know if I tab to a text box the entire text is selected but when I click
into a text box with a mask, the cursor is placed where I put it rather than
selecting the entire text box. this is a problem when masking for currency
for example. My mask is this: 999999.99

If I tab to the text box, I can type a number then a period then a number
and the decimal ends up in the right place and all seems good. But when I
click into the text box with the mouse, things go astray. I think it would
help to select the entire text regardless of whether the user tabs or clicks
into the box. But I can't seem to find out how to select the text. I tried
this:

Private Sub PkgCommAmtRcvd_Enter()
Me.PkgCommAmtRcvd.SelStart = 0
Me.PkgCommAmtRcvd.SelLength = 100
End Sub

But when I click into the box it still just selects 1 character. How can I
force it to always select the entire text?

Thanks,

Keith
 
 
 

select entire text in textbox

Post by Q2xpZmZvcm » Sun, 08 Mar 2009 04:57:01

Hi Keith,

The order of events when you click in a field is Enter, GotFocus,
Click. The order of events when you tab into a field is Enter, GotFocus. So
the click gets processed after you set the selection. I would suggest this:

Private Sub PkgCommAmtRcvd_GotFocus()

With PkgCommAmtRcvd
.SelStart = 0
.SelLength = Len(Nz(PkgCommAmtRcvd.InputMask, "")) + 1
End With

End Sub

Private Sub PkgCommAmtRcvd_Click()

PkgCommAmtRcvd_GotFocus

End Sub

Clifford Bass

 
 
 

select entire text in textbox

Post by Keith G Hi » Sun, 08 Mar 2009 09:34:48

That did it. Than you. :-)
 
 
 

select entire text in textbox

Post by Q2xpZmZvcm » Sat, 14 Mar 2009 01:58:01

Hi Keith,

Glad to hear it! You are welcome.

Clifford Bass