April 30, 2008

Add sounds to your Access form events

Date: April 29th, 2008

Author: Mary Ann Richardson

Would you like a sound to play each time a user opens or closes a form or clicks on a form control? Access lets you play a sound for any form event. For example, to have a sound play when a form is opened, follow these steps:

  1. Open the Form in Design View.
  2. Press Alt + F11.
  3. Go to View | Project Explorer.
  4. Insert | New Module.
  5. Enter this code at the prompt:

Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal filename As String, ByVal snd_async As Long) As Long Function Playsound(sWavFile As String) 'Purpose: Plays a sound. 'Argument: the fu11 path and file name. If apisndPlaySound(sWavFile, 1) = 0 Then MsgBox "The Sound Did Not Play!" End If End Function

  1. Press Alt + Q.
  2. On the form’s Property sheet, click in the OnOpen event box on the Event tab.

  1. Click the Build button and then enter the code below at the prompt. (Be sure to use the full pathname to your sound file.)
  2. viagra for sale in ireland

Playsound ("C:I386Chimes.wav")

  1. Press Alt + Q.
Permalink • Print • Comment
Made with WordPress and Semiologic • Sky Gold skin by Denis de Bernardy