Playing .wav files

  • Thread starter Thread starter Thomas
  • Start date Start date
T

Thomas

Hi,

Can I make access play .wav files, when I click on a
button in a form? Are there any tutorials on how to do
this?

Thanks,
Thomas
 
From My Files ---

(See below my SIG)


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

Play A Sound In Any Event



To play a sound in any event, just set an event such as a form's OnOpen to:

=PlaySound("C:\WINDOWS\CHIMES.WAV")

Paste the following declaration and function into a module and save:


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 full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
 
I did this, and I get an error stating...

The expression OnOpen you entered as the event proprty settingproduced the
following error: The expression you entered has a function name that
MyDatabaseName can't find.

Rick
 
Did you paste the code into a standard module as is?

In your expression that looks like this, did you spell "PlaySound" correctly?

=PlaySound("C:\WINDOWS\CHIMES.WAV")

Steve
PC Datasheet
 
Also, assuming you saved the module you pasted the code into, make sure you
didn't name the module PlaySound. The module name cannot be the same as any
functions or subs.
 
I created a new module calld PlaySound and pasted the following:
----------------------------------------------
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 full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function
 
See Doug's post for the problem!


Rick said:
I created a new module calld PlaySound and pasted the following:
----------------------------------------------
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 full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function
----------------------------------------
My spelling seems correct. I am using Access 2000.


Rick
 
See Doug's post for the problem!

Actually, Doug's post contains the solution. <g>
 
Technically you can't provide a solution without identifying the problem. Doug's
post did both so you and I are both only fifty percent correct. <g>

Steve
PC Datasheet
 
Back
Top