Play an Audio File with MS Access

Posted on 2013-01-14
Last Modified: 2013-01-14
I need to play an audio file in a loop when an MS Access app loads. How can I do this?
Question by:EMCIT
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
  • 3
  • 3
  • 2
LVL 61

Expert Comment

ID: 38775334
Application.FollowHyperlink "yourpath\yourfile.ext"

Will open the file.

Place that code in the open event of whatever form opens when the database starts up.
LVL 11

Author Comment

ID: 38775374
Thank you. It opens the file fine but i need it to run in a loop.
LVL 61

Expert Comment

ID: 38775386
How are you defining when to stop?

Do until...
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!

LVL 61

Assisted Solution

mbizup earned 250 total points
ID: 38775397
You can also put the application.followhyperlink statement into your forms timer event and set the timer interval property to define how fast it runs.

For example 5000 for every five seconds.
LVL 11

Author Comment

ID: 38775443
I tried it in the timer interval and it works but it also launches Media Player each time and it takes the focus from the form. If it runs on a loop On Load the window can be minimized to get it out of the way. Or is there a method to play the wav file without launching the player?
LVL 57

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 38775452
Not sure what type of file your planning to play, but this is the old way of doing it:

 which you can set to loop when you make the call.

LVL 57
ID: 38775473
You can also use code like the sample below to play MDI or MP3 files.


Private Declare Function mciSendString Lib "winmm.dll" Alias _
   "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
   lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
   hwndCallback As Long) As Long

Dim sMusicFile As String

Dim Play

Private Sub cmdPlayMusic_Click()

    sMusicFile = Me.txtFileName.Text    'path has been included. Ex. "C:\3rdMan.mp3"

    Play = mciSendString("play " & sMusicFile, 0&, 0, 0)

    If Play <> 0 Then MsgBox "Can't PLAY!"

    Me.cmdPlayMusic.Enabled = False
    Me.cmdStopMusic.Enabled = True

End Sub

Private Sub cmdStopMusic_Click()
    Play = mciSendString("close " & sMusicFile, 0&, 0, 0)

    cmdPlayMusic.Enabled = True
    cmdStopMusic.Enabled = False
End Sub
LVL 57
ID: 38775645
BTW, here's a better link which has the possible flags that you can pass:



Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

732 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