Canceling OnKeyUp Event within a module

  • Thread starter Thread starter CES
  • Start date Start date
C

CES

All,

I was wondering if someone might be able to help me figure out how to cancel the onKeyUp action if the current key being pressed is the tab key.

I realize this syntax is not correct but it will give you an idea of what I'm looking to do

Private Sub Field_Enter()

If Me.OnKeyUp = TabKey then ' I'm need to test to see if the key being pressed is the tab key
' if the current key being pressed use the tab key I want to suppress the onKeyUp event

Cancel on key up event (will not fire) 'if the tab key is the key pressed being pressed then I don't want the event to fire.

End if

Me.Field.DoSomething

End Sub

The problem that I am running into is that, the OnKeyUp event is interfering with some work that I need to do wen the focus changes to the current field. I'm running into the same problem when I use either the onFocus or onEnter events.

Thanks in advance. - CES
 
Hi CES,

You need to use the keydown event like this:

Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
End If

End Sub

Hope this helps.

Damian.
 
Back
Top