ACC: How to Play .WAV Sounds on Events in Microsoft AccessID: Q95647
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
Microsoft Access does not have a built-in function to play sound files on
events, such as when a form is opened or closed. However, you can use the
Microsoft Windows 3.1 application program interface (API) through Access
Basic code to create a user-defined function to play sound files.
This article assumes you are familiar with Access Basic and Windows APIs.
In this article, the use of error trapping has been omitted to keep the
information as clear and concise as possible.
Follow these steps to create a user-defined function to play sound files:
'*****************************************************************
'Declarations section of the module.
'*****************************************************************
Option Explicit
Declare Function sndplaysound% Lib "mmsystem" (ByVal filename$, _
ByVal snd_async%)
'================================================================
' The following function PlaySound calls the Windows API function
'================================================================
Function PlaySound (msound)
Dim XX%
XX% = sndplaysound(msound, 1)' play mmwave sound
If XX% = 0 Then MsgBox "The Sound Did Not Play!"
End Function
Object: Command Button
-------------------------------------------
Name: Push_Button_1
Caption: Play Chimes
On Click: =PlaySound("C:\WINDOWS\CHIMES.WAV")
(Where C:\WINDOWS\ is the location of the sound file and CHIMES.WAV
is the sound file.)
Microsoft Access "Introduction to Programming," Chapters 1-5
"Microsoft Windows Software Development Kit," Microsoft Press, 1992
"Programming Windows: the Microsoft Guide to Writing Applications for
Windows 3", Charles Petzold. Microsoft Press, 1990
"Programmer's Reference Library: Microsoft Windows 3.1 Guide to Programming
Reference," Volumes 1 - 6, Microsoft Press, 1992
Additional query words: sound api how to
Keywords : kbprg
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 18, 1999