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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.