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

textbox cursor placement

3 views
Skip to first unread message

jo...@graham.ca

unread,
Jan 12, 2006, 9:10:35 AM1/12/06
to
Hi, I am trying to get a textbox in a form to display a partial item
entry, i.e. "WER-5-" as most item serial numbers contian this value.
I want the cursor at the end of this text but it is always at the
beginning. How do I get it at the end. I remember at one faking
character input to do something similar but can't remember how I did it.

Steve

unread,
Jan 12, 2006, 9:35:44 AM1/12/06
to
If you want to simulate keypresses, you can use SendKeys. For this
situation, specifically, you'd probably want to use:
SendKeys("{END}")

to simulate using the END key to move your cursor to the line.

To simulate typing "WER-5", you'd do basically the same thing:
SendKeys("WER-5")

However, there are other ways to put text in a textbox. Most often used
is txtBox="TextToPutIn" . After assigning the text, you would then use
the SendKeys("{END}") to move the cursor.

Lyle Fairfield

unread,
Jan 12, 2006, 9:36:37 AM1/12/06
to
You could try (in the Form module, assuming the text box is called
"Text0")

Private Sub Text0_GotFocus()
Text0.SelStart = Len([Text0].Text)
End Sub

I have not used this extensively and it seems rather clumsy. I hope
someone else will have a better solution.

Wayne Morgan

unread,
Jan 12, 2006, 9:41:37 AM1/12/06
to
In the Enter event for the textbox, try:

Me.txtNameOfTextbox.SelStart = 6

That should move the cursor to the end of the 6th character. If you want the
rest of the text highlighted, that can be done also by adding a SelLength
statement after the SelStart statement.

--
Wayne Morgan
MS Access MVP


<jo...@graham.ca> wrote in message
news:1137075035....@f14g2000cwb.googlegroups.com...

0 new messages