Can you tell me wich is the ascii code for the enter button please and can you tell me also if this code is correct:
numibesiCode:Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 28 Then
Command1_Click
End If
End Sub
Printable View
Can you tell me wich is the ascii code for the enter button please and can you tell me also if this code is correct:
numibesiCode:Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 28 Then
Command1_Click
End If
End Sub
If you set the form's KeyPreview property to true, then that's fine. Also, I would suggest using the constant vbKeyEnter rather than a number.
Change 28 to 13, which is the Ascii for Enter/Return
Code:Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 28 Then
Call Command1_Click
End If
End Sub
It doesn´t work, it could be probabli because the 28 isn´r the nr for the enter button on ascii code.
Thank you megatron, but i was looking for other threads and i found that i could use vbKeyReturn insted of vbKeyEnter that doesn´t work.
Thank you both, numibesi