Hi
Anybody know what key / keycode to use to exit a combobox on sheet (control elements).
It seems that I have to use the mouse. That can't be true or....:confused:
BR
Tommy Bak
Printable View
Hi
Anybody know what key / keycode to use to exit a combobox on sheet (control elements).
It seems that I have to use the mouse. That can't be true or....:confused:
BR
Tommy Bak
Hi Tommy,
I always use Esc if not having a predefined type of key press method.
hi zack
that's ok as an emergecy solution, but it would be nice to exit it with enter or tab or something like that (seems more natural to the user)
BR
Tommy Bak
Tommy,
Maybe you can figure this one out. I can use this code with a ListBox and it worked beautiful, but on a ComboBox, it doesn't work... (??)
KeyAscii 13 is the Enter key. You won't be able to (I don't think) use TAB unless you can find a way to integrate that into a routine with SendKeys maybe.Code:Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 13 Then
Sheets("Sheet1").Range("B6").Activate
End If
End Sub
Hi Tommy,
You can capture the tab key within the KeyDown event e.g.
HTHCode:Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Then Me.Range("B10").Select
End Sub
Dan
Dan! Beautiful!
Maybe that's where I was going wrong, the help files said vbKeyTab value was 0x9, but I never put in just 9. Doh! Would you know why this doesn't work well with the KeyPress method? I error out if I change it?
From the help file:-Quote:
Originally Posted by firefytr
A KeyPress event does not occur under the following conditions:
I think the first condition is the answer to your question. :cool:
- Pressing TAB
- Pressing ENTER
- Pressing an arrow key.
- When a keystroke causes the focus to move from one control to another.
Regards,
Daniel
Hi Dan
Thankyou very much, it works fine.
I thought I had tried that, but obviosly I hadn't
and thanks to you too, Zack, for your effort.
BR
Tommy Bak