PDA

View Full Version : Determining how a ComboBox was changed ...



vodkasoda
04-08-2009, 09:35 AM
I have a ComboBox with a Change Event procedure associated with it.

Is there any way, once I am directed into that procedure, that I can determine if the Change Event was triggered by a mouse selection from the drop-down list or by a key being pressed on the keyboard ?

Cosmo
04-08-2009, 01:25 PM
Try something like this:
Private keyPressedByUser As Boolean
Private Sub ComboBox1_Change()
If keyPressedByUser Then
MsgBox "Key pressed"
keyPressedByUser = False
End If
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
keyPressedByUser = True
End Sub

You'll may need to edit the KeyDown function to test which keys were pressed