Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re:Sound in Access97/DevEdt on Win98/SE 2

Status
Not open for further replies.

KirkJewell

Programmer
Oct 6, 2000
54
GB
I have found examples of how to play sounds in Access97 but they never seem to work (although I don't get errors).

Can anyone help with the code required to play a .wav file? [sig][/sig]
 
Yep I used it a lot....

' ----------------------- Put this in a Module -------------
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

' for playing sounds (each one is listed below in detail)
Global Const KEY_RETURN = &HD
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
'-----------------------------------------------------------

'----------------- Put this in a sub to play a wav file ----
x% = sndPlaySound("c:\wavs\beep.wav", SND_SYNC)
'-----------------------------------------------------------

' Specifies options for playing the sound using one or more of the following flags:
' SND_SYNC
' The sound is played synchronously and the function does
' not return until the sound ends.

' SND_ASYNC
' The sound is played asynchronously and the function
' returns immediately after beginning the sound.

' SND_NODEFAULT
' If the sound cannot be found, the function returns
' silently without playing the default sound.

' SND_LOOP
' The sound will continue to play repeatedly until

' sndPlaySound is called again with the lpszSoundName$
' parameter set to null. You must also specify the
' SND_ASYNC flag to loop sounds.

' SND_NOSTOP
' If a sound is currently playing, the function will
' immediately return False without playing the requested
' sound.

[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
Hi,
That code could come in handy sometime thanks DougP. [sig]<p>Rob Marriott<br><a href=mailto:rob@career-connections.net>rob@career-connections.net</a><br>[/sig]
 
Thank you very much.

It Worked a treat.

Nice and short too.

This will give my users a shock if they have speakers installed on their PC's.

Regards Kirk

[sig][/sig]
 
DOUGP:
I have put the code listed above in a Module named Sound.
I have a command named: cmdINFSVCMain

What do I put in the sub to activate a sound when the
cmdINFSVCMain is pressed?

I am using Access 2000 if that makes a difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top