Results 1 to 4 of 4

Thread: Defaulting a key to a event procedure

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    I have a text box and I want to be able to program it so that when you hit the "Enter" key, it automatically runs the event procedure of a button that I also have on the form. How can I do this?

    ------------------
    Ryan
    corneslen@hotmail.com
    ICQ# 47799046

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    Try this:

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
    KeyAscii = 0
    ' Remove the word Rem from the following line, if you also want to remove text from the TextBox when Enter is pressed
    Rem Text1.Text = ""
    Command1.Value = True
    End If
    End Sub


    P.S. This is post no. 9999...

    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: RZvika@netvision.net.il
    ICQ: 19552879



  3. #3

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Thanks! It works great.

    ------------------
    Ryan
    corneslen@hotmail.com
    ICQ# 47799046

  4. #4
    Guest

    Post

    how about the RaiseEvent command?

    RaiseEvent command1_click

    or does this only work in class modules?


    ------------------

    Wossname,
    Email me: wossnamex@talk21.com

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