Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting text within text

0 views
Skip to first unread message

John

unread,
Oct 6, 2008, 3:45:46 AM10/6/08
to
Hi

I have a bound field on a continuous form. Is there a way to insert some
text at the cursor location via code? How?

Thanks

Regards


Graham Mandeno

unread,
Oct 6, 2008, 4:32:24 AM10/6/08
to
Hi John

The beginning of the current selection in a textbox is given by the SelStart
property. The Length of the selection is SelLength. If no range is
selected then SelLength will be zero. In either case, SelStart gives the
cursor position. Note that SelStart is zero-based, so if it is 5, it means
*after* the 5th character.

So, to insert some text at the cursor, you could do something like this:

With txtMyTextBox
.Text = Left( .Text, .SelStart ) & strTextToInsert _
& Mid ( .Text, .SelStart+1)
' the following is optional
.SelStart = .SelStart + Len( strTextToInsert )
.SelLength = 0
End With

--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

"John" <in...@nospam.infovis.co.uk> wrote in message
news:%23tMMIe4...@TK2MSFTNGP06.phx.gbl...

0 new messages