Play a ".wav" file with Access

L

Les

Good day, could you tell me if this is possible, if so could you please
help with some code.

Thanks
 
D

Dirk Goldgar

Les said:
Hi Dirk, as a newbie i think this is outa reach for me. Thanks anyway

It really isn't that hard -- you just copy the code (from "*** Code
Start ***" to "*** Code End ***"), paste it into a new standard module,
save the module, and call the function fPlayStuff from your code. I can
probably talk you through it, if that's not enough for you to go on.
 
L

Les

Hi Dirk, thanks for your help, i have copied like you said and in the
form code under Private Sub Nortje_Click()
Module1.fPlayStuff
End Sub

It now gives me a Compile error: Argument not optional and highlites
the fPlayStuff ?

I am not sure what i am doing wrong ?
 
D

Dirk Goldgar

Les said:
Hi Dirk, thanks for your help, i have copied like you said and in the
form code under Private Sub Nortje_Click()
Module1.fPlayStuff
End Sub

It now gives me a Compile error: Argument not optional and highlites
the fPlayStuff ?

I am not sure what i am doing wrong ?
Hi Dirk, thanks for your help, i have copied like you said and in the
form code under Private Sub Nortje_Click()
Module1.fPlayStuff
End Sub

It now gives me a Compile error: Argument not optional and highlites
the fPlayStuff ?

I am not sure what i am doing wrong ?

You don't need the "Module1." qualifier, but the main problem is that
you have to pass the function the full path to the sound file that you
want to play. For example,

fPlayStuff "C:\My Path\MyFile.wav"

If the path to the file is held in a control on your form, you can refer
to it like this:

fPlayStuff Me!txtSoundFilePath

(substituting your control name for "txtSoundFilePath").
 
L

Les

Thank you so much Dirk, it works 100%. I am not a trained programmer
but a dabbler and it your help and patience that really motivates and
helps.

I am making a report in Access so will be knocking on your door more if
i may ?

Thanks again
 
D

Dirk Goldgar

Les said:
Thank you so much Dirk, it works 100%.
Excellent!

I am not a trained programmer
but a dabbler and it your help and patience that really motivates and
helps.

I am making a report in Access so will be knocking on your door more
if i may ?

By all means.
Thanks again

You're welcome.
 
L

Les

Sorry Dirk, just one more question; is it possible to store the wave
file within the database and not in a drive or folder ?
 
D

Dirk Goldgar

Les said:
Sorry Dirk, just one more question; is it possible to store the wave
file within the database and not in a drive or folder ?

Yes, it's possible -- you can save it as an OLE Object. However, you
can't then use the same mechanism to play it. You can use a Bound
Object Frame control to represent and play the sound file, provided that
you have a registered application that will play .wav files. Or, with
more code than you probably want to get involved with, you can extract
the .wav data from the field, store it in a temporary file, play it from
there using the code you already have, and then delete the temporary
file. However, I have a feeling you're not going to want to do that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top