H.4. Some Useful API Functions
Apart from the SetFormIcon function described in Chapter 14, this section is devoted to demonstrating how to use some useful API functions.
H.4.1. Play a Sound in Access
Rather than accept the default DoCmd.Beep to notify users of some event, you can offer something a bit more interesting and perhaps meaningful by playing a sound file of your choosing.
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As long) As Long ' The sound is played asynchronously and the function returns immediately ' after beginning the sound. To terminate a sound called with SND_ASYNC, call ' sndPlaySound with lpszSoundName set to NULL Public Const SND_ASYNC = &H1 ' The sound plays repeatedly until sndPlaySound is called again with the ' lpszSoundName parameter set to NULL. You must also specify SND_ASYNC with this 'flag Public Const SND_LOOP = &H8 ' The parameter specified by lpszSoundName points to an image of a waveform ' sound in memory Public Const SND_MEMORY = &H4 ' If the sound cannot be found, the function returns silently without ' playing the default sound Public Const SND_NODEFAULT = &H2 ' If a sound is currently playing, the function immediately returns FALSE without ' playing the requested sound Public Const SND_NOSTOP = &H10 ' The sound is played synchronously and the function does not return ' until the sound ends Public Const SND_SYNC = &H0 Public Sub PlayAnySound(lpszSoundName As String) ...