A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Play .wav file at DB start-up



 
 
Thread Tools Display Modes
  #1  
Old July 7th, 2007, 02:22 PM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default Play .wav file at DB start-up

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........
  #2  
Old July 7th, 2007, 05:36 PM posted to microsoft.public.access.gettingstarted
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default Play .wav file at DB start-up

Hi

Try this link

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


--
Wayne
Manchester, England.



"Chad" wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........

  #3  
Old July 7th, 2007, 06:40 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Play .wav file at DB start-up

You'll need to determine the exact path to folder Songs, and then use

Call PlaySound(strFolder & "Whoosh.wav")

Note that there are problems using the sndPlaySound function with long file
names. If you need to, check http://www.mvps.org/access/api/api0020.htm at
"The Access Web" for code to convert from long file names to short file
names.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Chad" wrote in message
news
Hello, I have a file named song1.wav and its in a folder named Songs. How
do
I have my database play this song at startup. I move my database to and
from
work so the file path wont be the same but the folder "Songs" is always
with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........



  #4  
Old July 7th, 2007, 06:44 PM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default Play .wav file at DB start-up

I found that prior and have no clue on what to place where so I didnt go any
further. Can you explain? Thanks!
--
Newbies need extra loven.........


"Wayne-I-M" wrote:

Hi

Try this link

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


--
Wayne
Manchester, England.



"Chad" wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........

  #5  
Old July 8th, 2007, 02:16 AM posted to microsoft.public.access.gettingstarted
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Play .wav file at DB start-up

Chad wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup.


Not know what this song is I sure hope you have the ability to
1) turn it off when playing
2) tell the app to never play that song again in the future.
Otherwise your users could get very irritated at you.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
  #6  
Old July 8th, 2007, 02:26 AM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default Play .wav file at DB start-up

its only a two second start up song! and I need to add click.wav files for my
img buttons... I have been trying to figure this out for a few days now can
someone give me an example of what I need to do? Im getting pieces of
information and I reserch it just to find out I have no clue what they are
talking about. Im just starting out with access so please explain. Thanks!
--
Newbies need extra loven.........


"Tony Toews [MVP]" wrote:

Chad wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup.


Not know what this song is I sure hope you have the ability to
1) turn it off when playing
2) tell the app to never play that song again in the future.
Otherwise your users could get very irritated at you.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

  #8  
Old July 8th, 2007, 04:38 PM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default Play .wav file at DB start-up

PACALA, The discussion Group isn’t a place to do business it’s a place to
help people! I think this is very unprofessional....

Newbies need extra loven.........


"PACALA" wrote:

NO PROBLEMS, CONTACT ME...
--
PACALA JAN [ACCESS DEVELOPER]
SEND 10$ TO...
ACCOUNT:
SK31 1100 0000 0026 1674 0428
SwiftCode: TATRSKBX
Tatra banka as,Hodzovo nam.3, 811 06 Bratislava

SKYPE: PACALA.BA1


"Chad" wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........

  #9  
Old July 8th, 2007, 06:10 PM posted to microsoft.public.access.gettingstarted
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default Play .wav file at DB start-up

Hi Chad

Playing a sound on various events in/on a form is quite simple (IF you know
how).

So 1st can we agree on my price.

I never charge less than one absolutely huge cream cake. You can send this
to me at Wayne-i-m c/o the British Post Office, England. I am sure it
will arrive sooner or later. Oh if a cream cake is too much I will let you
negotiate me down but no lower than a jam donut.

You say you have looked around for some help and can’t understand it – me
too, some of it, so don’t worry nothing is clear “until you get it, only then
is it simple.

If you have a look a the module on Allan Browns site
http://allenbrowne.com

You will it looks like this

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: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function


So – to use this - do this

In your access database you will have (on the left of the screen) choices of
Tables
Queries
Forms
Reports
Pages
Macros
Modules

Select Modules
Select New

You will arrive at a screen with
Option Compare Database

Cut and paste Allan’s code (paste just below Option Compare Database) it
will now look like this


Option Compare Database
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: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function

I drew the line in the code above as that is what you will see . Save this
as whatever you want (but something that makes sense to you AND more
importantly anyone else who may, in the future, work on the programming)


Next
Open your form in design view
Right click the form area outside the detail section (the grey area)
Select properties
Select the Event Column
Right click the OnLoad row
Select Build (…)
Select Code
You will see this

Private Sub Form_Load()


End Sub

You need to write only one line of code (like this)
PlaySound (Path to WAV file)

It will look something like (but not exactly like) this

Private Sub Form_Load()
PlaySound ("C:\WINDOWS\Media\chord.wav")
End Sub

OK up to now I hope. You MUST know the full path of the WAV.
You can get it by clicking
Start
Run
Browse
(Select all files in the file type box)
Navigate to your WAV file and select it.
Click run
Cut the path out of the run box and paste it into the code between the ( )

Hey-presto


Hope this helps

--
Wayne
Manchester, England.



"Chad" wrote:

PACALA, The discussion Group isn’t a place to do business it’s a place to
help people! I think this is very unprofessional....

Newbies need extra loven.........


"PACALA" wrote:

NO PROBLEMS, CONTACT ME...
--
PACALA JAN [ACCESS DEVELOPER]
SEND 10$ TO...
ACCOUNT:
SK31 1100 0000 0026 1674 0428
SwiftCode: TATRSKBX
Tatra banka as,Hodzovo nam.3, 811 06 Bratislava

SKYPE: PACALA.BA1


"Chad" wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........

  #10  
Old July 8th, 2007, 06:32 PM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default Play .wav file at DB start-up

Wayne, I really appreciate the well expalined post but I understand how to
make a module and where to put the code and how to find the path. My problem
is that I move that database around and the sound file wont be in the same
place as my home PC and work PC's. I wanted to do something as to where it
finds the path for example im using this in a report to bring up pictures
from a folder named RejectSteelBarCodes and this forlder always stays with my
DB. How would I incorporate something like this but use a folder named Sounds
to find the .wav file I am wanting? Oh and how about a delicious cookie baked
fresh from the oven instead of the cake....Thanks!

strPath = CurrentProject.Path & "\RejectSteelBarCodes\"
strDir = Dir(strPath)
--
Newbies need extra loven.........


"Wayne-I-M" wrote:

Hi Chad

Playing a sound on various events in/on a form is quite simple (IF you know
how).

So 1st can we agree on my price.

I never charge less than one absolutely huge cream cake. You can send this
to me at Wayne-i-m c/o the British Post Office, England. I am sure it
will arrive sooner or later. Oh if a cream cake is too much I will let you
negotiate me down but no lower than a jam donut.

You say you have looked around for some help and can’t understand it – me
too, some of it, so don’t worry nothing is clear “until you get it, only then
is it simple.

If you have a look a the module on Allan Browns site
http://allenbrowne.com

You will it looks like this

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: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function


So – to use this - do this

In your access database you will have (on the left of the screen) choices of
Tables
Queries
Forms
Reports
Pages
Macros
Modules

Select Modules
Select New

You will arrive at a screen with
Option Compare Database

Cut and paste Allan’s code (paste just below Option Compare Database) it
will now look like this


Option Compare Database
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: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function

I drew the line in the code above as that is what you will see . Save this
as whatever you want (but something that makes sense to you AND more
importantly anyone else who may, in the future, work on the programming)


Next
Open your form in design view
Right click the form area outside the detail section (the grey area)
Select properties
Select the Event Column
Right click the OnLoad row
Select Build (…)
Select Code
You will see this

Private Sub Form_Load()


End Sub

You need to write only one line of code (like this)
PlaySound (Path to WAV file)

It will look something like (but not exactly like) this

Private Sub Form_Load()
PlaySound ("C:\WINDOWS\Media\chord.wav")
End Sub

OK up to now I hope. You MUST know the full path of the WAV.
You can get it by clicking
Start
Run
Browse
(Select all files in the file type box)
Navigate to your WAV file and select it.
Click run
Cut the path out of the run box and paste it into the code between the ( )

Hey-presto


Hope this helps

--
Wayne
Manchester, England.



"Chad" wrote:

PACALA, The discussion Group isn’t a place to do business it’s a place to
help people! I think this is very unprofessional....

Newbies need extra loven.........


"PACALA" wrote:

NO PROBLEMS, CONTACT ME...
--
PACALA JAN [ACCESS DEVELOPER]
SEND 10$ TO...
ACCOUNT:
SK31 1100 0000 0026 1674 0428
SwiftCode: TATRSKBX
Tatra banka as,Hodzovo nam.3, 811 06 Bratislava

SKYPE: PACALA.BA1


"Chad" wrote:

Hello, I have a file named song1.wav and its in a folder named Songs. How do
I have my database play this song at startup. I move my database to and from
work so the file path wont be the same but the folder "Songs" is always with
the database. I have found the code below and it works but its pointing to
windows media folder ect. Here is the code:

Module:
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound(strSound)
Call sndPlaySound32(strSound, 0)
End Sub

On load event of my opening form:
Call PlaySound("C:\Windows\Media\Whoosh.wav")


Thanks!!!

--
Newbies need extra loven.........

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.