Disabling sound

I am using a form with multiple text boxes. I have entered code for a keypress event that accepts the Enter key, which moves focus to the next text box. When the app is running and I press  the Enter key to step to the next text box, I hear the selected windows sound for an error. If I press the Tab key, I do not get the sound. I do not want to turn the sound off in the Windows control panel - sounds. How can I disable the sound at the instant I press the Enter key? I do not want to disable the sound entirely, when the app is running.
Who is Participating?
adityauConnect With a Mentor Commented:
You can use KeyAscii = 0 in the KeyPress event event itself. If you don't use it, beep will come. If you say KeyAscii = 0 and set the focus to another text box, it does not give any beep.
Set KeyCode = 0 in the KeyDown event.
But only when KeyCode = 13 of course. ;)

If (KeyCode = vbEnter) Then
  KeyCode = 0
  'You have your setfocus code here perhaps?
End If

All Courses

From novice to tech pro — start learning today.