enter key and botton click

L

leanne

I would like at a text box hit enter key will act like a
botton click. But the following code doesn't work. Need
help.
Private Sub txtbox_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call btnOK_Click
KeyAscii = 0
End If

End Sub

Leanne
 
P

Pavel Romashkin

Try putting Call btnOK_Click in the After Update event of the text box.

Pavel
 
Top