Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Play an Audio File with MS Access

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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