Solved

Play an Audio File with MS Access

Posted on 2013-01-15
4
448 Views
Last Modified: 2013-01-21
I used the following code (obtained here yesterday):

'This function declaration must be entered onto a single line.
   Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
       (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

   Sub PlaySound()
       If Application.CanPlaySounds Then
           'Substitute the path and filename of the sound you want to play
           Call sndPlaySound32("c:\track2.wav", 0)
       End If
   End Sub

It works, in that it sets off a sound, but it appears to be the default system "Beep" instead of the specific wav file that I want to play. I appreciate your assistance.
0
Comment
Question by:EMCIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 57
ID: 38779710
Have you tried to play this:

"c:\track2.wav"

outside of your code?  (ie. right click in explorer and open)

 I don't see anything wrong.   And it is a valid wave file correct; not something you renamed to .wav?

Jim.
0
 
LVL 11

Author Comment

by:EMCIT
ID: 38779730
It is a valid wav file and I can play the file outside the code. I can't reach the person who sent me the file. If it was a non-wav file renamed would it be an issue?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38779851
<<If it was a non-wav file renamed would it be an issue? >>

 Possibly; it's the only thing I can think of.  Looks OK otherwise.  

But before we go too far, try adding SND_NODEFAULT to the call and make sure the path and file name are correct.

' Sound constants.
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

Jim.
0
 
LVL 11

Author Closing Comment

by:EMCIT
ID: 38802271
Thank you Jim. It was the file. I replaced it with a genuine wav file and it works as desired.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question