Results 1 to 2 of 2

Thread: Positioning cursor in text box

  1. #1
    Guest

    Post

    I can't seem to get the cursor back to the last position in the text box. Any ideas?

    Here is part of the code of the text box TxtConCan.Text. The user enter a key word then presses a logical opertor button. As it stands now, the usr has to manually place the cursor at the end of the text line before he/she can enter another keyword.

    thanks


    Option Explicit
    > ' Public Concanit As String
    > ' Public pintCount As Integer
    > ' Public pstrCountAnd As String
    > ' Public pstrCountOr As String
    > ' Public pstrCountExclude As String
    >
    > Private Sub btnand_Click()
    > Me.TxtConCan.SetFocus
    > Me.TxtConCan.Text = Me.TxtConCan.Text & " 'AND' "
    > Me.btnand.SetFocus
    > End Sub
    >
    > Private Sub btnandnot_Click()
    > Me.TxtConCan.SetFocus
    > Me.TxtConCan.Text = Me.TxtConCan.Text & " 'EXCLUDE' "
    > Me.btnandnot.SetFocus
    > End Sub
    >
    > Private Sub btnClose_Click()
    > DoCmd.close acForm, "frmRetrieve"
    > Forms![mainswitchboard].Visible = True
    > End Sub
    >
    > Private Sub btnor_Click()
    > Me.TxtConCan.SetFocus
    > Me.TxtConCan.Text = Me.TxtConCan.Text & " 'OR' "
    > Me.btnor.SetFocus
    > End Sub

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    In sytead of resetting the focus back to the button you've just clicked do this:

    TxtConCan.SelStart = Len(TxtConCan.Text)

    eg:
    Code:
    Private Sub btnand_Click()
     Me.TxtConCan.SetFocus
     Me.TxtConCan.Text = Me.TxtConCan.Text & " 'AND' "
     'Me.btnand.SetFocus
    TxtConCan.SelStart = Len(TxtConCan.Text)
     End Sub
    Is this any help?

    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width