I have a text box, with an OK, and a Cancel Button. I want it to execute the OK when I hit enter after typing in text on the text box. How would I do that?
If I understand what you are saying correctly set focus to the save cmd after the edit. You may have to play around with got focus and lost focus on the text box to do it.
The simplest way to do this is using the KeyPress event:
Code:
Private Sub txtYourTextbox_KeyPress(KeyAscii as Integer)
If (KeyAscii = vbKeyReturn) Then 'ENTER key is pressed
Call cmdYourCommandButton_Click()
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.