By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,248 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,248 IT Pros & Developers. It's quick & easy.

textbox cursor placement

P: n/a
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.

Jan 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

Jan 12 '06 #2

P: n/a
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.

Jan 12 '06 #3

P: n/a
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:11*********************@f14g2000cwb.googlegro ups.com...
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.

Jan 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.