Setting focus on textbox to auto select texbox value 
Author Message
 Setting focus on textbox to auto select texbox value

I am slowly leaning how to use VBA userforms and come across a problem that
I cannot solve on my own. I have a text box (TBnamedind2) with a preset
properties value <type name> . When the user selects a checkbox
(CBnamedind2) I have set the focus in code to this textbox but the curser
goes to the end of <type name> even with 'Wordautoselect' set to true. I
would like the value <type name> to be selected so the user could just start
typing and not have to delete the preset value. Could anybody point me in
the right direction? Thanks


Wed, 17 Sep 2003 21:16:10 GMT  
 Setting focus on textbox to auto select texbox value
Hi Andrew,

To set the focus on the TextBox and select all the text in it use:

With TBnamedind2
    .SetFocus
    .SelStart = 0
    .SelLength = Len(.Text)
End With

--
Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.


Quote:
> I am slowly leaning how to use VBA userforms and come across a problem
that
> I cannot solve on my own. I have a text box (TBnamedind2) with a preset
> properties value <type name> . When the user selects a checkbox
> (CBnamedind2) I have set the focus in code to this textbox but the curser
> goes to the end of <type name> even with 'Wordautoselect' set to true. I
> would like the value <type name> to be selected so the user could just
start
> typing and not have to delete the preset value. Could anybody point me in
> the right direction? Thanks



Wed, 17 Sep 2003 22:06:43 GMT  
 Setting focus on textbox to auto select texbox value
Thanks Ibby it works a treat. I suspected it might be simple ( if you knew
how) but I had not come across the selxxxx bits before. I have just learnt
another bit of code.

With TBnamedind2
    .SetFocus
    .SelStart = 0
    .SelLength = Len(.Text)
End With


Quote:
> I am slowly leaning how to use VBA userforms and come across a problem
that
> I cannot solve on my own. I have a text box (TBnamedind2) with a preset
> properties value <type name> . When the user selects a checkbox
> (CBnamedind2) I have set the focus in code to this textbox but the curser
> goes to the end of <type name> even with 'Wordautoselect' set to true. I
> would like the value <type name> to be selected so the user could just
start
> typing and not have to delete the preset value. Could anybody point me in
> the right direction? Thanks



Thu, 18 Sep 2003 19:26:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Auto-select Textbox on Form Load

2. HLP: MAKING TEXBOX LOOSE FOCUS

3. How to keep focus after catching tab key in texbox

4. selecting text in TextBox upon getting focus

5. How do I set focus to and show cursor on textbox on form activate

6. Missing cursor on set focus of textbox

7. Set focus on textbox in datagrid

8. Can not set Focus to textbox

9. Can't set input focus to textbox

10. Setting Focus on a Mobile TextBox

11. setting focus to textbox without using Javascript

12. Web Form: How to set focus on a textbox

 

 
Powered by phpBB® Forum Software