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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADDING A WAV SOUND TO A BUTTON

Status
Not open for further replies.

csegal

Technical User
Jun 12, 2001
38
US
I would like to play a wav file when a button is pressed. is this possible using access 97?

csegal
csegal@arrowair.com
 
Here's some code I got someplace. This should do it for you.
Code:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

 Function PlaySound(FileName As String)
    
    Dim MyReturn As Long
    
    MyReturn = sndPlaySound(FileName, 1)
    If (MyReturn <> 1) Then GoTo ErrHandler
    
'********************
'*  Exit Procedure  *
'********************
        
ExitProcedure:

    Exit Function

'****************************
'*  Error Recovery Section  *
'****************************
        
ErrHandler:
        
    Msgbox &quot;Error from sndPlaySound&quot; & vbCrLf & &quot;Value is &quot; & MyReturn, vbExclamation

    GoTo ExitProcedure

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top