Sound plays before form displays

G

Guest

Hello

I am trying to play a WAV file when my form opens.
I have used the code found at

http://www.mvps.org/access/api/api0011.htm

which is refered to in previous threads, and this works fine except that the
WAV plays before the form displays. I am using the code in the forms On Open
event, but I have also tried On Load with same result. I have also tried a
DoEvents statement before the code which plays the WAV but this has no effect
iether. Could someone point me in the right direction?

Any help gratefully received.

Wes.
 
M

Marshall Barton

Wez.k said:
I am trying to play a WAV file when my form opens.
I have used the code found at

http://www.mvps.org/access/api/api0011.htm

which is refered to in previous threads, and this works fine except that the
WAV plays before the form displays. I am using the code in the forms On Open
event, but I have also tried On Load with same result. I have also tried a
DoEvents statement before the code which plays the WAV but this has no effect
iether.


Try running the code the first time the Current event fires:

Sub Form_Current(...
Static WavPlayed As Boolean
If Not WavPlayed Then
' your wav code here
WavPlayed = True
End If
' any other code for the Current event
End Sub
 
G

Guest

Thanks for yuour reply Marshall. I have tried what you suggest but am still
getting the same result. Code is as follows:

Private Sub Form_Current()
Static WavPlayed As Boolean

If Not WavPlayed Then

PlaySound ' your wav code here

WavPlayed = True

End If

End Sub

Private Sub PlaySound()

If Len(Nz("C:\SYM/Sounds/qopen_2000.WAV", "")) = 0 Then

' No sound file path present so just ignore
' You could also play a "No Sound" file
' or a Windows one if desired

Else

' Sound file path present
strPath = "C:\SYM/Sounds/qopen_2000.WAV"
fPlayStuff (strPath)

End If

End Sub

Function fPlayStuff is as copied from the weblink

Any ideas?
 
M

Marshall Barton

Wez.k said:
Thanks for yuour reply Marshall. I have tried what you suggest but am still
getting the same result. Code is as follows:

Private Sub Form_Current()
Static WavPlayed As Boolean

If Not WavPlayed Then
PlaySound ' your wav code here
WavPlayed = True
End If

End Sub


The Current event is triggered before the form is
displayed???

How about moving that code to the Activate event?

If that doesn't work either, the only other place I can
think of is the GotFocus event of the first (tab order)
control on the form.
 
G

Guest

Hi Marshall, nope, it just doesn't want to play ball!

I think I'll just forget it. Could you help me with one other thing? I
have used the FSO to create a folder, but the folder is being created with
the Read Only attribute set. Is it possible to re-set it to Normal, or have
it created that way in the first place?
 
M

Marshall Barton

I think you can come close enough if you play the sound
asynchronously. Just change the one line to:
fPlayStuff strPath, 1
Try the Load event again so you don't have to mess with the
first time stuff.

I don't use FSO. It's just another library reference to
worry about, especially since I have never run into a
situation where the built in VBA statements didn't take care
of what I wanted. Maybe all you need is to use MkDir.
Check VBA Help for details and, while you're there, check
SetAttr.
 
G

Guest

Thanks Marshall, thats fixed it!

Marshall Barton said:
I think you can come close enough if you play the sound
asynchronously. Just change the one line to:
fPlayStuff strPath, 1
Try the Load event again so you don't have to mess with the
first time stuff.

I don't use FSO. It's just another library reference to
worry about, especially since I have never run into a
situation where the built in VBA statements didn't take care
of what I wanted. Maybe all you need is to use MkDir.
Check VBA Help for details and, while you're there, check
SetAttr.
--
Marsh
MVP [MS Access]


Wez.k said:
Hi Marshall, nope, it just doesn't want to play ball!

I think I'll just forget it. Could you help me with one other thing? I
have used the FSO to create a folder, but the folder is being created with
the Read Only attribute set. Is it possible to re-set it to Normal, or have
it created that way in the first place?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top