Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Set Focus to End of Text in Form Control (2002 10.4302.4219 SP-2)

    I have two related controls on a form; an Option Bpx control and a Text control. Based on the Option Box selection, standardized language is generated and placed in the Text Box control. In several cases the use needs to append/add addtional text. Subsequent to an Option Box selection, the text box gets the focus and the entered text is selected. As a non-typist I simply click the mouse at the end of the text and enter addtional information. However, for a typist this is too slow to take her hands off the keyboard. I've not been able to figure out how to automatically put the cursor at the end any text in the text box when it gets the focus from the Option Box. There surely must be a simple way to do this that thus far is eluding me.

    Thanks in advance for your insights.
    Marty

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set Focus to End of Text in Form Control (2002 10.4302.4219 SP-2)

    Say that the text box is named txtSomething. You could use code like this:

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

    Note: the SelLength, SelStart and Text properties are only available when the text box has the focus, so you must set the focus before using these properties.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Focus to End of Text in Form Control (2002 10.4302.4219 SP-2)

    Hans's solution is good for your situation as described.

    Don't forget about F2 key to deselect and position pointer at end of data for other situations.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Set Focus to End of Text in Form Control (2002 10.4302.4219 SP-2)

    Hans:

    Thanks very much for the great and simple tip. Looks to provide exactly the solution I wanted.

    Marty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •