Solved

Play an Audio File with MS Access

Posted on 2013-01-14
8
346 Views
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?
0
Comment
Question by:EMCIT
  • 3
  • 3
  • 2
8 Comments
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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.
0
 
LVL 11

Author Comment

by:EMCIT
Comment Utility
Thank you. It opens the file fine but i need it to run in a loop.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
How are you defining when to stop?

Do until...
     Application.followhyperlink...
Loop
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 250 total points
Comment Utility
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.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Author Comment

by:EMCIT
Comment Utility
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?
0
 
LVL 57

Accepted Solution

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

http://support.microsoft.com/kb/158140

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

Jim.
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
You can also use code like the sample below to play MDI or MP3 files.

Jim.

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
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
BTW, here's a better link which has the possible flags that you can pass:

http://support.microsoft.com/kb/86281

You want SND_ASYNC + SND_LOOP

Jim.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

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

10 Experts available now in Live!

Get 1:1 Help Now