Results 1 to 11 of 11
  1. #1
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13

    Specified .WAV file not playing on Form Open

    I created a new module (below) to play sound (Gorilla Breaths) when a form is open. Code works but plays a chime sound instead of selected wave file. I am a novice at writing code. What am I not doing or missing for the sound not to play? Any help would be appreciated.

    Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
    (ByVal filename As String, ByVal snd_async As Long) As Long
    Function PlaySound(sWavFile As String)
    ' Purpose: Plays a sound.
    ' Argument: "W:\\CFFSRV004\ISGROUPS\!_ITAdministration\Admin\J UNIOR\Gorilla.wav".
    If apisndPlaySound(sWavFile, 1) = 0 Then


    MsgBox "The Sound Did Not Play!"
    End If
    End Function

    Private Sub Form_Open(Cancel As Integer)
    PlaySound ("W:\\CFFSRV004\ISGROUPS\!_ITAdministration\Admin\ JUNIOR\Gorilla.wav")
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try it without the double "\\"'s
    ("W:\CFFSRV004\...
    ...or maybe just leave off the drive:
    ("\\CFFSRV004\..

  3. #3
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Tried both suggestions. No success. Wondering if I should record sound and play with command button.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Can you copy that .wav file to the local drive?

  5. #5
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Thanks RG. Copying file to local drive and pointing to it in code worked well (see revised below). Trouble is, others who will use database do not have access to my local drive. Database is stored on a shared drive. Any clues on how to get around this so that others can hear sound as well and not get an error message disallowing them from viewing form because .wav file can't be found?

    Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
    (ByVal filename As String, ByVal snd_async As Long) As Long
    Function PlaySound(sWavFile As String)
    ' Purpose: Plays a sound.
    ' Argument: "C:\Users\WilsonE\Music\Gorilla.wav".
    If apisndPlaySound(sWavFile, 1) = 0 Then
    MsgBox "The Sound Did Not Play!"
    End If
    End Function


    Private Sub Form_Open(Cancel As Integer)
    PlaySound ("C:\Users\WilsonE\Music\Gorilla.wav")
    End Sub

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It should be playable from a Public folder on a Public drive as long as the path is set properly. What path did you use the copy the file?

  7. #7
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    C:\Users\WilsonE\Music\Gorilla.wav

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I meant the source, sorry.

  9. #9
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Appreciate the help, RG. Sound is now playing on form open, from Public Folder.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Thanks for the update. Was it the path?

  11. #11
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Yes. The path was the culprit. Removing the extra detail '\\....\' corrected things. Probably too much guesswork for the application to sort through....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open pdf file from Access form
    By lios1984 in forum Access
    Replies: 7
    Last Post: 02-21-2012, 01:11 PM
  2. Replies: 5
    Last Post: 08-20-2011, 01:08 PM
  3. Replies: 1
    Last Post: 09-27-2010, 10:10 AM
  4. Can not open File already in use.
    By Wrangler in forum Access
    Replies: 1
    Last Post: 03-04-2009, 09:50 PM
  5. How to stop sound playing
    By trirat in forum Programming
    Replies: 0
    Last Post: 03-12-2006, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums