Ommand button KeyPress/Up/Down events

  • Thread starter Thread starter Dinky
  • Start date Start date
D

Dinky

Hi,
I've been trying to get a keyPress/KeyDown/KeyUp event to work for a
command button so that when the user presses tab it'll shift focus
somewhere else

This is the sub for it:
Private Sub cmdOpenCal_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox ("A key has been pressed")
If KeyCode = vbKeyTab Then
Me!frmsubCustOrders!cboSelectcustomer.SetFocus
MsgBox ("KeyCode = vbKeyTab")
Else
MsgBox ("KeyCode != vbKeyTab")
End Sub

The problem is that when the command button has focus and I press a key
(any key apart from enter etc which will effictively click on the
button and run the onclick event handler instead) nothing happens.

The message boxes are there to see if the event handler is even run but
they do not pop up indicating that the event handler is not entered at
all.

I have also tried creating a text box and put a key event handler for
it but that does not respond either.

What could be the problem? I can figure it out.

Thanks
 
Back
Top