INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Play .WAV files in Access

How do I play a wav file in Access by DougP
Posted: 12 Oct 00

There are 2 parts to playing a .WAV file in Access or VB
1. Need to declare the sndPlaySound function in the winmm.dll file.
2. Call the sndPlaySound function as shown below.

' ----------------------- 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.

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close