Play a sound at a certain time in access

  • Thread starter Thread starter bmcnulty
  • Start date Start date
B

bmcnulty

I am looking to play a certain sound in Access every three minutes,
then a minute after that (so play a sound after 3 minutes, then 4
minutes, then 7 minutes, then 8 minutes, etc). I know about the
"Timer" Function, but I think you can only use one number for that.
Any suggestions? Thanks!
 
You can reset the TimerInterval in the Timer event.

For example, you can set TimerInterval to 180000 (3 minutes) when you load
the form, then in the Timer event, set it to 60000 (1 minute)
 
I'm not real familiar with the Timer and TimerInterval commands. Any
chance you can give me a sample code? Thanks and sorry.
 
There's not a whole lot to show.

In the form's Load event, you need a line of code:

Me.TimerInterval = 180000

The value specifies the interval, in milliseconds, between Timer events on a
form. (0 means the Timer event never fires, 180000 in the example above is
180 seconds, or 3 minutes)

You then put code for the form's Timer event:

Private Sub Form_Timer()

Me.TimerInterval = 60000

' Code to play your sound here

End Sub

If you're not familiar with how to play the sound, see
http://www.mvps.org/access/api/api0011.htm at "The Access Web"
 
Doug,

I tried to do the WAV file code, but the code is just too confusing to
me. Instead, I used background colors.

What I wanted to do was set up a bell tone to play on the times of a
regulation boxing match. I'm starting a boxing regiment and I thought
what a great way to train if I could set up a bell to ring to end a
round (after 3 minutes) and then again to start the next round (after 1
minute). Instead, I used green and red background colors on the detail
section.

Thanks again for your help.

Bryan
 
The code to play a WAV file isn't that difficult to use.

Create a new module (not a class module), and copy everything in the shaded
part of the web page (what's between Code Start and Code End) and paste it
into the module. Save the module (making sure you don't name the module the
same as any of the routines stored within it)

To play the WAV file, use:

Dim strWAVFile As String

strWAVFile = "C:\Folder\File.WAV"

fPlayStuff strWAVFile, pcsASYNC

If I recall correctly, the path to the WAV file must be in 8.3 format: it
cannot include long file names, nor blanks. Assuming you've got a long file
name, see http://www.mvps.org/access/api/api0020.htm for a routine to
convert the long file name to its short file name equivalent.

Again, you copy the code from the shaded part into a new module. You'd then
use

strWAVFile = fGetShortName("C:\My Documents\My Music\MyLongFileName.WAV")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top