Results 1 to 4 of 4

Thread: hitting return in a text box?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 1999
    Posts
    56

    Post

    How do I make a command button keep focus while the user is typing in a text box? Dialog boxes have this feature so that when the user finishes typing, he/she can just hit enter. My form has several text boxes and several command buttons. I want each text box to have a cooresponding command button. Thanks in advance.

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Posts
    28

    Post

    Hi I think that this will work

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = Chr(13) Then
    {Put the code that is in the Command1_click in here}
    end if
    End Sub

    Hope that it Works

  3. #3
    Member
    Join Date
    Feb 2000
    Posts
    43

    Post

    instead of copying over the code from command1_click ... you can just call the command1_click procedure

    and chr(13) should just be 13 I believe


    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    command1_click
    end if

    end sub




    ------------------
    Rapmaster

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 1999
    Posts
    56

    Post

    Thanks guys. The code works great. I don't know why I didn't think if it before... ;-)
    There is one thing though. My text boxes are not multilined, of course, and whenever the I hit enter, the Windows default sound plays. Is there anyway to prevent that? Multilined text boxes would execute the return and then my code. Thanks again.

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