>>>Hello Gurus!
>>>
>>>Problem today..........
>>>
>>>I have a textbox where I input text.... the text is used to filter a grid in realtime on the form....
>>>
>>>but... the user can TAB out of the textbox and tab to other controls, and THEN tab back into the textbox.
>>>
>>>The Text is now HIGHLIGHTED and SELECTED. When the user types into the textbox, the text disappears and is replaced with NEW text.
>>>
>>>I wanted the new text to append to the end of what text was already in the textbox.
>>>
>>>Is there a property to set this?
>>>
>>>Thanks!
>>
>>To append text add this to the WHEN of the textbox:
>>
>>This.SelStart = LEN(ALLTRIM(this.Value))
>
>Bernard,
>
>Shouldn't that be
This.SelStart = LEN(TRIM(This.Value)) + 1
to account for blank spaces at the start of the text and to avoid overwriting the last letter or the text?
>
>Regards,
Hi Jim
Yes you are partly right.It should be TRIM rather than ALLTRIM to preserve the blank spaces at the start.
And no, it should not be +1 as this adds a spurious space after the last character.
The correct code is :
This.SelStart = LEN(TRIM(This.Value))
The Help file says of SelStart:
...indicates the position of the insertion point. ...The valid range of settings is 0 to the total number of characters in the edit area of the control.
Thus the insertion point for string "12345" will be after the "5" since the insertion point is counted as starting from 0 not starting from 1.
This can easily be verified by actually adding this code to a form and testing the code.