Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enter key detection, uding "afterUpdate" event

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
I need to detect when enter was clicked, NOT on "field_onkey_press" event, but on "field_AfterUpdate" event. I guess I just need to know, what's the command for detecting the ascii code of chrs.
Thanks in advance
P.s - of cousr I need itto be in vba (is there other option anyway?)
 
You probably need to do it in two steps, first capture the keystroke for that control, set a module level variable based on the key pressed, then check the results of the variable in your AfterUpdate Event. Remember to set the Form's Key Preview property to Yes.

Dim blnReturnKey As Boolean 'module level variable

Private Sub ControlName_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyReturn
blnReturnKey = True
Case Else
blnReturnKey = False
End Select
Exit Sub

Private Sub ControlName_AfterUpdate()
If blnReturnKey = True Then
'Do This
Else
'Do That
End If


PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top