J
Jon Lewis
I'm using a Form's KeyDown event to trap Alt + a letter in order to assign
access keys to command buttons that have custom images consisting of picture
plus text. It seems that whenever a KeyDown event is executed as a result
of Alt + a letter there is an annoying error 'beep' as the event ends. (It's
the same 'beep' you get when you click on another window when a modal dialog
box is open.) Sample code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Form_KeyDown
If KeyCode = vbKeyC And (Shift And acAltMask) Then
Call cmdClose_Click 'NO BEEP presumably as the Form is closed
ElseIf KeyCode = vbKeyM And (Shift And acAltMask) Then
'Call cmdComplete_Click ''Beep' produced
MsgBox "M" 'Beep produced
End If
Exit_Form_KeyDown:
Exit Sub
Err_Form_KeyDown:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Form_KeyDown
End Sub
The 'Beep' happens at the Exit Sub line (or End Sub if there's no error
handling). It only happens trapping Shift plus KeyCode NOT KeyCode on its
own. I even tried setting Shift to 0 in the code to no avail. Access 97 not
Windows version dependent.
I can't figure out how to get rid of the 'Beep'. Any ideas anyone?
TIA.
access keys to command buttons that have custom images consisting of picture
plus text. It seems that whenever a KeyDown event is executed as a result
of Alt + a letter there is an annoying error 'beep' as the event ends. (It's
the same 'beep' you get when you click on another window when a modal dialog
box is open.) Sample code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Form_KeyDown
If KeyCode = vbKeyC And (Shift And acAltMask) Then
Call cmdClose_Click 'NO BEEP presumably as the Form is closed
ElseIf KeyCode = vbKeyM And (Shift And acAltMask) Then
'Call cmdComplete_Click ''Beep' produced
MsgBox "M" 'Beep produced
End If
Exit_Form_KeyDown:
Exit Sub
Err_Form_KeyDown:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Form_KeyDown
End Sub
The 'Beep' happens at the Exit Sub line (or End Sub if there's no error
handling). It only happens trapping Shift plus KeyCode NOT KeyCode on its
own. I even tried setting Shift to 0 in the code to no avail. Access 97 not
Windows version dependent.
I can't figure out how to get rid of the 'Beep'. Any ideas anyone?
TIA.