KeyPress Event and Enter key 
Author Message
 KeyPress Event and Enter key

Hi, everyone.

I'd like to respond to users pressing Enter key. There is an Event
called KeyPress. However, it does NOT respond to Enter key.

This is what I want to do; when users press Enter key after typing a
number in a textbox, I'd like the action to be tantamount to pressing
Tab key, so that they can move to the next tab order control.

There is a code for VB, but I doubt we can use it for Excel VBA...

Private Sub Text1_Keypress(ByVal KeyAscii As MSForms.ReturnInteger)
    if keyAscii = vbKeyreturn then
        SendKeys "[Tab]"
        KeyAscii = 0
    End If
End Sub

Thanks,  Tetsuya Oguma, Sydney,  Australia



Thu, 06 Feb 2003 12:25:03 GMT  
 KeyPress Event and Enter key
Tet,
Just set the EnterKeyBehavior property to false.

On Sun, 20 Aug 2000 14:25:03 +1000, Tetsuya Oguma

Quote:

>Hi, everyone.

>I'd like to respond to users pressing Enter key. There is an Event
>called KeyPress. However, it does NOT respond to Enter key.

>This is what I want to do; when users press Enter key after typing a
>number in a textbox, I'd like the action to be tantamount to pressing
>Tab key, so that they can move to the next tab order control.

>There is a code for VB, but I doubt we can use it for Excel VBA...

>Private Sub Text1_Keypress(ByVal KeyAscii As MSForms.ReturnInteger)
>    if keyAscii = vbKeyreturn then
>        SendKeys "[Tab]"
>        KeyAscii = 0
>    End If
>End Sub

>Thanks,  Tetsuya Oguma, Sydney,  Australia

Ray Costanzo

http://www.excelfiles.com


Thu, 06 Feb 2003 12:35:48 GMT  
 KeyPress Event and Enter key
Tetsuya

The keypress event can change the value of the key before executing the
keypress, so just replace the Enter with a Tab like this:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Chr(13) Then KeyAscii = Chr(9)
End Sub

Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Chr(13) Then KeyAscii = Chr(9)
End Sub

Best wishes Harald



Quote:
> Hi, everyone.

> I'd like to respond to users pressing Enter key. There is an Event
> called KeyPress. However, it does NOT respond to Enter key.

> This is what I want to do; when users press Enter key after typing a
> number in a textbox, I'd like the action to be tantamount to pressing
> Tab key, so that they can move to the next tab order control.

> There is a code for VB, but I doubt we can use it for Excel VBA...

> Private Sub Text1_Keypress(ByVal KeyAscii As MSForms.ReturnInteger)
>     if keyAscii = vbKeyreturn then
>         SendKeys "[Tab]"
>         KeyAscii = 0
>     End If
> End Sub

> Thanks,  Tetsuya Oguma, Sydney,  Australia



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Enter key not triggering ActiveX ctl KeyPress event

2. RETURN key does not fire KeyDown/KeyPress event

3. No DELETE key acknowledgement wih KeyPress event

4. Creating Custom Event Handler (KeyPress Event)

5. Assigning event to Shift-Tab in KeyPress event

6. detecting keyup event on Enter key

7. Trigger Event With Enter Key

8. Event on ENTER key stroke?

9. Capturing ENTER keypress

10. Combobox.KeyPress does not react to Enter


 
Powered by phpBB® Forum Software © phpBB Group