Using The Enter Key In The Enhanced Data Form
My Enhanced Data Form is an add-in that provides a data entry dialog box for any worksheet database. Pressing the Tab key while this dialog box is active activates the next control in the dialog box.
Several users have asked me if there's a way to use the Enter key to move among the fields. There is, but it requires some additional programming. I updated the Enhanced Data Form Customizing page with this code: Using the Enter key to move among the fields.
- Reader Comments -
Following are comments in response to this item.
The most recent comment is at the bottom.
- By Harald Staff. Comment posted 23 October, 2008 10:00amJohn;
I wonder if you could simplify by replacing the ascii in KeyDown (I'm not knowing this specific form or sourecode):
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then KeyCode = 9
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then KeyCode = 9
End Sub
Best wishes Harald - By John Walkenbach. Comment posted 23 October, 2008 10:22amGood point, Harald. I forgot about that KeyDown event. That would certainly be better than SendKeys.
I'll re-visit my code and see if I can get it work. - By John Walkenbach. Comment posted 23 October, 2008 12:53pmAfter giving it some thought, Harald's idea won't work for the Enhanced Data Form. The TextBox and ComboBox controls are generated on the fly. Using the KeyDown even would require code that writes an event procedure for each control. It could be done by using a class module, but that would require quite a bit of changes.
- By Harald Staff. Comment posted 25 October, 2008 7:21amI see, that complicates it. Oh well ..
Spreadsheet Page Blog
Welcome to the Spreadsheet Page Blog. This is where you find the latest news on my books, add-ins, and other Excel-related topics. Comments are welcome.