?
Solved

Play an Audio File with MS Access

Posted on 2013-01-15
4
Medium Priority
?
458 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 58
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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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 …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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