KeyDown Event and vbKeyNumpad (?)

C

croy

The boss would like the short code for species to be the
visible field in the combobox, but he would also like to be
able to assign numeric values of 1 thru 10 for the most
popular species, that data-entry folks can key in without
having to move their hand away from the numeric keypad.

I don't know if this is a good approach or not, but I put
this code on the field:

Private Sub cboSpeciesId_KeyDown(KeyCode As Integer, Shift
As Integer)

*****
Select Case KeyCode
Case vbKeyNumpad1
KeyCode = 0
Me![cboSpeciesId] = 1
Case vbKeyNumpad2
KeyCode = 0
Me![cboSpeciesId] = 13
Case vbKeyNumpad3
KeyCode = 0
Me![cboSpeciesId] = 11
Case vbKeyNumpad4
KeyCode = 0
Me![cboSpeciesId] = 20
Case vbKeyNumpad5
KeyCode = 0
Me![cboSpeciesId] = 15
Case vbKeyNumpad6
KeyCode = 0
Me![cboSpeciesId] = 2
Case vbKeyNumpad7
KeyCode = 0
Me![cboSpeciesId] = 7
Case vbKeyNumpad8
KeyCode = 0
Me![cboSpeciesId] = 17
Case vbKeyNumpad9
KeyCode = 0
Me![cboSpeciesId] = 8
End Select
End Sub
*****

It works very well, except for the first Case: when I press
"1" on the numeric keypad, nothing is entered in the field.
It doesn't seem strange at all to me that one of them
doesn't work--that's usually the case with things that I
try. But it does seem strange that all the other Cases
work!

However, I would be perfectly happy with an explanation of
why the first Case doesn't work!
 
C

croy

On Wed, 21 Nov 2007 11:55:23 -0800, croy <[email protected]>
wrote:


I've tried to rescind this post, but that doesn't seem to
work.

The problem I was having was due to a filter that I had long
forgotten about.
 
D

Dirk Goldgar

croy said:
The boss would like the short code for species to be the
visible field in the combobox, but he would also like to be
able to assign numeric values of 1 thru 10 for the most
popular species, that data-entry folks can key in without
having to move their hand away from the numeric keypad.

I don't know if this is a good approach or not, but I put
this code on the field:

Private Sub cboSpeciesId_KeyDown(KeyCode As Integer, Shift
As Integer)

*****
Select Case KeyCode
Case vbKeyNumpad1
KeyCode = 0
Me![cboSpeciesId] = 1
Case vbKeyNumpad2
KeyCode = 0
Me![cboSpeciesId] = 13
Case vbKeyNumpad3
KeyCode = 0
Me![cboSpeciesId] = 11
Case vbKeyNumpad4
KeyCode = 0
Me![cboSpeciesId] = 20
Case vbKeyNumpad5
KeyCode = 0
Me![cboSpeciesId] = 15
Case vbKeyNumpad6
KeyCode = 0
Me![cboSpeciesId] = 2
Case vbKeyNumpad7
KeyCode = 0
Me![cboSpeciesId] = 7
Case vbKeyNumpad8
KeyCode = 0
Me![cboSpeciesId] = 17
Case vbKeyNumpad9
KeyCode = 0
Me![cboSpeciesId] = 8
End Select
End Sub
*****

It works very well, except for the first Case: when I press
"1" on the numeric keypad, nothing is entered in the field.
It doesn't seem strange at all to me that one of them
doesn't work--that's usually the case with things that I
try. But it does seem strange that all the other Cases
work!

However, I would be perfectly happy with an explanation of
why the first Case doesn't work!



Works for me with a text box. Could it be that the value 1 that you're
assigning when the key 1 is pressed, isn't in the combo box's rowsource?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top