Exceladd1ct
Board Regular
- Joined
- Feb 10, 2019
- Messages
- 76
I am trying to set focus and activate the dropdown of a combobox in the After_Update Subroutine of a Textbox. After filling in some text, if i move focus away from the textbox by mouse click, it works fine, if i move the focus away by pressing enter key, it jumps to the 3rd textbox instead of combobox.
I managed to do the job with KeyDown event but, what am i missing? why does it jump to txtbox3 when pressing enter key?
I managed to do the job with KeyDown event but, what am i missing? why does it jump to txtbox3 when pressing enter key?
VBA Code:
Private Sub TextBox1_afterupdate()
Call combo
End Sub
'Without this, it won't work
Private Sub textbox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If TextBox1.Value <> "" Then
combo
Exit Sub
End If
End If
End Sub
Function combo()
UserForm4.ComboBox1.SetFocus
UserForm4.ComboBox1.DropDown
End Function