Module 1
Option Compare Database
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
'-----------------------------------------------------------
Module 2
Function Import_Ads()
' 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.
On Error GoTo ImportAds_Resume
DoCmd.DeleteObject acTable, "Unisys Ads"
ImportAds_Resume:
Dim Message As String
DoCmd.SetWarnings False
'Do While Message <> "1"
x% = sndPlaySound("\\10.25.13.180\aimstuff\jeopardy[1].wav", SND_ASYNC)
DoCmd.TransferText acImportFixed, "Unisys Ads Import", "Unisys Ads", "l:\mar2006.txt", False, ""
DoCmd.OpenQuery "Trim Spaces from Unisys Ad #", acViewNormal, acReadOnly
DoCmd.SetWarnings True
DoCmd.DeleteObject acTable, "mar2006_ImportErrors"
'----------------- Put this in a sub to play a wav file ----
'x% = sndPlaySound("c:\documents and settings\dheichelbech\my documents\my music\fdone10[1].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.
x% = sndPlaySound("c:\documents and settings\dheichelbech\my documents\my music\fdone10[1].wav", SND_ASYNC)
Message = MsgBox("Process Completed")
ImportAds_Exit:
Exit Function
Import_Unisys_Ads_Err:
MsgBox Error$
Resume ImportAds_Exit
'Loop
End Function
The song plays when the button is clicked