Play an Audio File with MS Access

I need to play an audio file in a loop when an MS Access app loads. How can I do this?
LVL 11
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
EMCITAuthor Commented:
Thank you. It opens the file fine but i need it to run in a loop.
How are you defining when to stop?

Do until...
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

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.
EMCITAuthor Commented:
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?
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
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
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
BTW, here's a better link which has the possible flags that you can pass:


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.