Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I play a wav file in Access

Play .WAV files in Access

How do I play a wav file in Access

by  DougP  Posted    (Edited  )
There are 2 parts to playing a .WAV file in Access or VB
1. Need to declare the sndPlaySound function in the winmm.dll file.
2. Call the sndPlaySound function as shown below.

' ----------------------- Put this in a Module -------------
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

' for playing sounds (each one is listed below in detail)
Global Const KEY_RETURN = &HD
Global Const SND_SYNC = &H0
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Global Const SND_LOOP = &H8
Global Const SND_NOSTOP = &H10
'-----------------------------------------------------------

'----------------- Put this in a sub to play a wav file ----
x% = sndPlaySound("c:\wavs\beep.wav", SND_SYNC)
'-----------------------------------------------------------

' Specifies options for playing the sound using one or more of the following flags:
' SND_SYNC
' The sound is played synchronously and the function does
' not return until the sound ends.

' SND_ASYNC
' The sound is played asynchronously and the function
' returns immediately after beginning the sound.

' SND_NODEFAULT
' If the sound cannot be found, the function returns
' silently without playing the default sound.

' SND_LOOP
' The sound will continue to play repeatedly until

' sndPlaySound is called again with the lpszSoundName$
' parameter set to null. You must also specify the
' SND_ASYNC flag to loop sounds.

' SND_NOSTOP
' If a sound is currently playing, the function will
' immediately return False without playing the requested
' sound.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top