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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top