Advertisement
2002ASP Custom Controls/ Forms/ Menus #462

Enter to Tab

This code gives the "enter" key the same functionality as the "tab" key in a vb form. When the user presses the "enter" key, it moves the focus to the next control, based on the tab index order. Don't forget to set the KeyPreview property of the form to True. (My thanks to Pennington. His TabToEnter2 code laid the foundation for this code.)

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'add this to your form's code
Private Sub Form_KeyPress(KeyAscii As Integer)
 
 'catch both "Enter" keys on keyboard
 If (KeyAscii = vbKeyReturn) Or (KeyAscii = vbKeySeparator) Then
  SendKeys "{tab}"
 End If
End Sub
Original Comments (3)
Recovered from Wayback Machine