textbox cursor placement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • johnk@graham.ca

    #1

    textbox cursor placement

    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

    #2
    Re: textbox cursor placement

    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="TextToP utIn" . After assigning the text, you would then use
    the SendKeys("{END} ") to move the cursor.

    Comment

    • Lyle Fairfield

      #3
      Re: textbox cursor placement

      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.

      Comment

      • Wayne Morgan

        #4
        Re: textbox cursor placement

        In the Enter event for the textbox, try:

        Me.txtNameOfTex tbox.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


        <johnk@graham.c a> wrote in message
        news:1137075035 .232992.87140@f 14g2000cwb.goog legroups.com...[color=blue]
        > 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.
        >[/color]


        Comment

        Working...