O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

F.4. Some Useful API Functions

Apart from the SetFormIcon function described in Chapter 13, this section is devoted to demonstrating how to use some useful API functions.

F.4.1. Play a Sound in Access

Rather than accept the default DoCmd.Beep to notify users of some event, you can offer something bit more interesting and perhaps meaningful by playing any sound file you happen to have.

Public Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long Public Const SND_ASYNC = &H1 'The sound is played asynchronously 'and the function returns immediately 'after beginning the sound. 'To terminate an asynchronously played 'sound, call sndPlaySound with 'lpszSoundName set to NULL. Public Const SND_LOOP = &H8 'The sound plays repeatedly until 'sndPlaySound is called again with the 'lpszSoundName parameter set to NULL. 'You must also specify the SND_ASYNC 'flag to loop sounds. Public Const SND_MEMORY = &H4 'The parameter specified by lpszSoundName 'points to an image of a waveform sound 'in memory. Public Const SND_NODEFAULT = &H2 'If the sound cannot be found, the 'function returns silently without 'playing the default sound. Public Const SND_NOSTOP = &H10 'If a sound is currently playing, the 'function immediately returns FALSE, 'without playing the requested sound. Public Const SND_SYNC = &H0 'The sound is played synchronously and 'the function does not return until the 'sound ends. Public Sub PlayAnySound(lpszSoundName ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required