Add sounds to your Access form events

Your forms don't have to be silent and boring -- Access lets you play a sound for any form event. Here's a quick look at how you can set up Access to play a sound each time a user opens or closes a form or clicks on a form control.

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.)

Playsound ("C:I386Chimes.wav")

  1. Press Alt + Q.

Miss an Access tip?

Check out the Microsoft Access archive and catch up on other Access tips.

Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.


this is what came up when I searched TR for an answer on how to add a sound, other than the generic Beep, to Access. This post is a variation of the same answer I was finding at Microsoft and search engines. For Access 2003, however, it does not work. I finally found one that does work and it is here: Just thought you'd like to know. Tink :)


Can a copy of the .wav file be stored within the Access database? This would help when sharing the database with other users who have different setups, for example different versions of Windows. They may not have the same sound files, or they may have them in a different default location.


I'm a little lost as to why you can't just have the form call the apisndPlaySound function directly, instead of going through a user function PlaySound(). Is it just to give you a place to pop up the dialog box if the api call fails?

Editor's Picks