Solved

Play an Audio File with MS Access

Posted on 2013-01-15
4
421 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restoring a form to its default settings 3 27
Macro to import XML in Access 2013 2 40
Filter a form 8 15
Access Delete Query Not Working 13 33
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

803 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