use the .setfocus method of the control you'd like to move to in the keypress method of the control that is receiving the keypress. Check keyascii for the value 13.
Further..the annoying beep can be supressed by setting keyascii=0 once you've determined the value of it.
Private Sub Control1_KeyPress(KeyAscii As Integer)
'move to next control
If KeyAscii = 13 Then 'enter key was pressed
KeyAscii = 0 'supress beep
Control2.SetFocus
End If
End If
End Sub
These work without knowing the next control to TAB to.
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
KeyCode = 0
Text1.Enabled = False
Text1.Enabled = True
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
KeyCode = 0
sendkeys "{tab}"
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.