Solved

Play an Audio File with MS Access

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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
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
Comment Utility
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
Comment Utility
<<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
Comment Utility
Thank you Jim. It was the file. I replaced it with a genuine wav file and it works as desired.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now