obiwan444
July 16th, 2001, 10:58 AM
This is a very wierd issue which occurs on one form of an MDI application I am working on. I have placed toolbars at the bottoms of my forms to replace having a row of command buttons (just for looks). Unfortunately I lost the keyhandlers that came along with the command buttons and had to write them manually in the keydown event handler of the form. This works great on 4/5 forms in the app. On one form however, I always get a beep when an alt+key sequence is pressed. I'm trapping the alt+key sequences and calling the cooresponding sub after setting the keycode=0, but I still get the beep. Other forms using similar logic/code do not beep. Below is my code ... does anyone have a suggestion of something I may be overlooking?
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim AltDown As Integer
AltDown = (Shift And vbAltMask) > 0
KeyAscii = Asc(UCase(Chr(KeyCode)))
' ignore function keys
If KeyCode >= vbKeyF1 And KeyCode <= vbKeyF16 Then
KeyCode = 0
Exit Sub
End If
' if the alt key is pressed, check for alt+key combinations
If AltDown Then
Select Case KeyAscii
Case vbKeyN: KeyCode = 0: cmdCollectionsAdd_Click
Case vbKeyC: KeyCode = 0: cmdCaseAdd_Click
Case vbKeyL: KeyCode = 0: cmdCollectionsDelete_Click
Case vbKeyB: KeyCode = 0: cmdDebtorDelete_Click
Case vbKeyS: KeyCode = 0: cmdCaseDelete_Click
Case vbKeyG: KeyCode = 0: cmdSaveChanges_Click
Case vbKeyR: KeyCode = 0: cmdDebtorAdd_Click
End Select
End If ' if alt key down
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim AltDown As Integer
AltDown = (Shift And vbAltMask) > 0
KeyAscii = Asc(UCase(Chr(KeyCode)))
' ignore function keys
If KeyCode >= vbKeyF1 And KeyCode <= vbKeyF16 Then
KeyCode = 0
Exit Sub
End If
' if the alt key is pressed, check for alt+key combinations
If AltDown Then
Select Case KeyAscii
Case vbKeyN: KeyCode = 0: cmdCollectionsAdd_Click
Case vbKeyC: KeyCode = 0: cmdCaseAdd_Click
Case vbKeyL: KeyCode = 0: cmdCollectionsDelete_Click
Case vbKeyB: KeyCode = 0: cmdDebtorDelete_Click
Case vbKeyS: KeyCode = 0: cmdCaseDelete_Click
Case vbKeyG: KeyCode = 0: cmdSaveChanges_Click
Case vbKeyR: KeyCode = 0: cmdDebtorAdd_Click
End Select
End If ' if alt key down
End Sub