Prevent move next on Enter

J

Jesper Fjølner

I'm using the folto prevent users from 'tabbing' out of a field.

Private Sub ControlName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab And Shift = 0 Then
KeyCode = 0
End If
End Sub

Can I do the same for the Enter-button?
If KeyCode = vbKeyReturn Then
KeyCode =0
End if
doesn't seem to work?

In the database options I've set the database to move to the next field on
Enter - does this complicate it?
Could it be something with the previewing of the keystrokes in field/form?
Thanks for your help.
 
J

Jesper Fjølner

Can I do the same for the Enter-button?
If KeyCode = vbKeyReturn Then
KeyCode =0
End if
doesn't seem to work?

Got it working with
If KeyCode = 13 Then
KeyCode =0
End if
 

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