Answer: It is possible to play wav files within your Access database.
To do this, create a new Module and paste in the following VBA code:
Const SND_ASYNC = (1)
Const SND_NODEFAULT = (2)
Declare Function sndplaysound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Sub API_PlaySound(pWavFile As String)
Dim LResult As Long
'Make a Windows API call to play a wav file
LResult = sndplaysound(pWavFile, SND_NODEFAULT + SND_ASYNC)
End Sub
Your module should look like this:
You can now make a call to this function with your wav file name as follows:
Private Sub Command1_Click()The code above would play the wav file called chimes.wav that is located in the c:\windows\media directory. You can choose when to play the wav file (ie: when a form opens, when a button is clicked, etc)
API_PlaySound "c:\windows\media\chimes.wav"
End Sub
No comments:
Post a Comment