PC Review


Reply
Thread Tools Rate Thread

Calling A Module

 
 
Martin Tudge
Guest
Posts: n/a
 
      18th Sep 2003
Hi All
I have created a module called 'Soundthings' to play a
sound within Access.
Beliow is the procedures I have put into the module.
The only issue now is how do i call up the procedure
below to play the sound.

Hope someone can help.
Regards
Martin
________________________________________________
Option Compare Database
Option Explicit

Declare Function sndPlaySound Lib "Winmm.dll"
Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
ByVal uFlags As Long) As Long
Public Const KEY_RETURN = &HD
Public Const SND_SYNC = &H0
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
Public Const SND_LOOP = &H8
Public Const SND_NOSTOP = &H10

Public Sub PlaySound(pFile As String)

sndPlaySound pFile, SND_SYNC
End Sub

Public Sub PlayIntro()
Dim s As String
s = DBEngine(0)(0).Name
While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1): Wend
s = s & "SETUP0.WAV"

PlaySound s

End Sub

 
Reply With Quote
 
 
 
 
Joe Fallon
Guest
Posts: n/a
 
      18th Sep 2003
These are the 3 functions that I use to play wav files.
I CALL it in the form open event like this:

PlaySound ("The Microsoft Sound.wav")

Paste these 3 functions into a Module:
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal
filename As String, ByVal snd_async As Long) As Long
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long


Public Function PlaySound(msound)
Dim XX%
Dim rtn As Integer
rtn = waveOutGetNumDevs() 'check for a sound card in the machine
If rtn = 1 Then 'a sound card exists
XX% = apisndPlaySound(msound, 1) 'play mmwave sound
Else ' no sound card was found
End If

'If XX% = 0 Then MsgBox ("The Sound Did Not Play! Because you don't have a
sound card.")
End Function

--
Joe Fallon
Access MVP



"Martin Tudge" <(E-Mail Removed)> wrote in message
news:0c8d01c37dbb$2370b090$(E-Mail Removed)...
> Hi All
> I have created a module called 'Soundthings' to play a
> sound within Access.
> Beliow is the procedures I have put into the module.
> The only issue now is how do i call up the procedure
> below to play the sound.
>
> Hope someone can help.
> Regards
> Martin
> ________________________________________________
> Option Compare Database
> Option Explicit
>
> Declare Function sndPlaySound Lib "Winmm.dll"
> Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
> ByVal uFlags As Long) As Long
> Public Const KEY_RETURN = &HD
> Public Const SND_SYNC = &H0
> Public Const SND_ASYNC = &H1
> Public Const SND_NODEFAULT = &H2
> Public Const SND_LOOP = &H8
> Public Const SND_NOSTOP = &H10
>
> Public Sub PlaySound(pFile As String)
>
> sndPlaySound pFile, SND_SYNC
> End Sub
>
> Public Sub PlayIntro()
> Dim s As String
> s = DBEngine(0)(0).Name
> While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1): Wend
> s = s & "SETUP0.WAV"
>
> PlaySound s
>
> End Sub
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      18th Sep 2003
Thanks for that, but I am still having trouble.
The sound file I am trying to play is called SETUP0.WAV
and is in the same folder as the database.
Please break this down for me as it is really complicated.
Cheers.

>-----Original Message-----
>These are the 3 functions that I use to play wav files.
>I CALL it in the form open event like this:
>
>PlaySound ("The Microsoft Sound.wav")
>
>Paste these 3 functions into a Module:
>Declare Function apisndPlaySound Lib "winmm"

Alias "sndPlaySoundA" (ByVal
>filename As String, ByVal snd_async As Long) As Long
>Declare Function waveOutGetNumDevs Lib "winmm.dll" () As

Long
>
>
>Public Function PlaySound(msound)
> Dim XX%
> Dim rtn As Integer
> rtn = waveOutGetNumDevs() 'check for a sound card in

the machine
> If rtn = 1 Then 'a sound card exists
> XX% = apisndPlaySound(msound, 1) 'play mmwave sound
> Else ' no sound card was found
> End If
>
> 'If XX% = 0 Then MsgBox ("The Sound Did Not Play!

Because you don't have a
>sound card.")
>End Function
>
>--
>Joe Fallon
>Access MVP
>
>
>
>"Martin Tudge" <(E-Mail Removed)> wrote in message
>news:0c8d01c37dbb$2370b090$(E-Mail Removed)...
>> Hi All
>> I have created a module called 'Soundthings' to play a
>> sound within Access.
>> Beliow is the procedures I have put into the module.
>> The only issue now is how do i call up the procedure
>> below to play the sound.
>>
>> Hope someone can help.
>> Regards
>> Martin
>> ________________________________________________
>> Option Compare Database
>> Option Explicit
>>
>> Declare Function sndPlaySound Lib "Winmm.dll"
>> Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
>> ByVal uFlags As Long) As Long
>> Public Const KEY_RETURN = &HD
>> Public Const SND_SYNC = &H0
>> Public Const SND_ASYNC = &H1
>> Public Const SND_NODEFAULT = &H2
>> Public Const SND_LOOP = &H8
>> Public Const SND_NOSTOP = &H10
>>
>> Public Sub PlaySound(pFile As String)
>>
>> sndPlaySound pFile, SND_SYNC
>> End Sub
>>
>> Public Sub PlayIntro()
>> Dim s As String
>> s = DBEngine(0)(0).Name
>> While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1):

Wend
>> s = s & "SETUP0.WAV"
>>
>> PlaySound s
>>
>> End Sub
>>

>
>
>.
>

 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      19th Sep 2003
Paste these 3 functions into a Module means you copy and paste the code into
a module and then save the module using a name like module1.

Then you go to a form and edit it.
In the form open event you write this code:

PlaySound ("SETUP0.WAV")

Then you run the form.
The sound plays when the form opens.
--
Joe Fallon
Access MVP



"Martin" <(E-Mail Removed)> wrote in message
news:01eb01c37e0e$d688d740$(E-Mail Removed)...
> Thanks for that, but I am still having trouble.
> The sound file I am trying to play is called SETUP0.WAV
> and is in the same folder as the database.
> Please break this down for me as it is really complicated.
> Cheers.
>
> >-----Original Message-----
> >These are the 3 functions that I use to play wav files.
> >I CALL it in the form open event like this:
> >
> >PlaySound ("The Microsoft Sound.wav")
> >
> >Paste these 3 functions into a Module:
> >Declare Function apisndPlaySound Lib "winmm"

> Alias "sndPlaySoundA" (ByVal
> >filename As String, ByVal snd_async As Long) As Long
> >Declare Function waveOutGetNumDevs Lib "winmm.dll" () As

> Long
> >
> >
> >Public Function PlaySound(msound)
> > Dim XX%
> > Dim rtn As Integer
> > rtn = waveOutGetNumDevs() 'check for a sound card in

> the machine
> > If rtn = 1 Then 'a sound card exists
> > XX% = apisndPlaySound(msound, 1) 'play mmwave sound
> > Else ' no sound card was found
> > End If
> >
> > 'If XX% = 0 Then MsgBox ("The Sound Did Not Play!

> Because you don't have a
> >sound card.")
> >End Function
> >
> >--
> >Joe Fallon
> >Access MVP
> >
> >
> >
> >"Martin Tudge" <(E-Mail Removed)> wrote in message
> >news:0c8d01c37dbb$2370b090$(E-Mail Removed)...
> >> Hi All
> >> I have created a module called 'Soundthings' to play a
> >> sound within Access.
> >> Beliow is the procedures I have put into the module.
> >> The only issue now is how do i call up the procedure
> >> below to play the sound.
> >>
> >> Hope someone can help.
> >> Regards
> >> Martin
> >> ________________________________________________
> >> Option Compare Database
> >> Option Explicit
> >>
> >> Declare Function sndPlaySound Lib "Winmm.dll"
> >> Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
> >> ByVal uFlags As Long) As Long
> >> Public Const KEY_RETURN = &HD
> >> Public Const SND_SYNC = &H0
> >> Public Const SND_ASYNC = &H1
> >> Public Const SND_NODEFAULT = &H2
> >> Public Const SND_LOOP = &H8
> >> Public Const SND_NOSTOP = &H10
> >>
> >> Public Sub PlaySound(pFile As String)
> >>
> >> sndPlaySound pFile, SND_SYNC
> >> End Sub
> >>
> >> Public Sub PlayIntro()
> >> Dim s As String
> >> s = DBEngine(0)(0).Name
> >> While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1):

> Wend
> >> s = s & "SETUP0.WAV"
> >>
> >> PlaySound s
> >>
> >> End Sub
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
Martin Tudge
Guest
Posts: n/a
 
      19th Sep 2003
Hi Joe
Did what you said and got an error message saying 'The
macro(or its macro group) doesn't exist,'
Do you think its because I am using access 97 on a windows
xp pc?
Regards
Martin
>-----Original Message-----
>Paste these 3 functions into a Module means you copy and

paste the code into
>a module and then save the module using a name like

module1.
>
>Then you go to a form and edit it.
>In the form open event you write this code:
>
>PlaySound ("SETUP0.WAV")
>
>Then you run the form.
>The sound plays when the form opens.
>--
>Joe Fallon
>Access MVP
>
>
>
>"Martin" <(E-Mail Removed)> wrote in message
>news:01eb01c37e0e$d688d740$(E-Mail Removed)...
>> Thanks for that, but I am still having trouble.
>> The sound file I am trying to play is called SETUP0.WAV
>> and is in the same folder as the database.
>> Please break this down for me as it is really

complicated.
>> Cheers.
>>
>> >-----Original Message-----
>> >These are the 3 functions that I use to play wav files.
>> >I CALL it in the form open event like this:
>> >
>> >PlaySound ("The Microsoft Sound.wav")
>> >
>> >Paste these 3 functions into a Module:
>> >Declare Function apisndPlaySound Lib "winmm"

>> Alias "sndPlaySoundA" (ByVal
>> >filename As String, ByVal snd_async As Long) As Long
>> >Declare Function waveOutGetNumDevs Lib "winmm.dll" ()

As
>> Long
>> >
>> >
>> >Public Function PlaySound(msound)
>> > Dim XX%
>> > Dim rtn As Integer
>> > rtn = waveOutGetNumDevs() 'check for a sound card in

>> the machine
>> > If rtn = 1 Then 'a sound card exists
>> > XX% = apisndPlaySound(msound, 1) 'play mmwave sound
>> > Else ' no sound card was found
>> > End If
>> >
>> > 'If XX% = 0 Then MsgBox ("The Sound Did Not Play!

>> Because you don't have a
>> >sound card.")
>> >End Function
>> >
>> >--
>> >Joe Fallon
>> >Access MVP
>> >
>> >
>> >
>> >"Martin Tudge" <(E-Mail Removed)> wrote in message
>> >news:0c8d01c37dbb$2370b090$(E-Mail Removed)...
>> >> Hi All
>> >> I have created a module called 'Soundthings' to play

a
>> >> sound within Access.
>> >> Beliow is the procedures I have put into the module.
>> >> The only issue now is how do i call up the procedure
>> >> below to play the sound.
>> >>
>> >> Hope someone can help.
>> >> Regards
>> >> Martin
>> >> ________________________________________________
>> >> Option Compare Database
>> >> Option Explicit
>> >>
>> >> Declare Function sndPlaySound Lib "Winmm.dll"
>> >> Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
>> >> ByVal uFlags As Long) As Long
>> >> Public Const KEY_RETURN = &HD
>> >> Public Const SND_SYNC = &H0
>> >> Public Const SND_ASYNC = &H1
>> >> Public Const SND_NODEFAULT = &H2
>> >> Public Const SND_LOOP = &H8
>> >> Public Const SND_NOSTOP = &H10
>> >>
>> >> Public Sub PlaySound(pFile As String)
>> >>
>> >> sndPlaySound pFile, SND_SYNC
>> >> End Sub
>> >>
>> >> Public Sub PlayIntro()
>> >> Dim s As String
>> >> s = DBEngine(0)(0).Name
>> >> While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1):

>> Wend
>> >> s = s & "SETUP0.WAV"
>> >>
>> >> PlaySound s
>> >>
>> >> End Sub
>> >>
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      19th Sep 2003
No.
There is something else wrong.
Perhaps you are using an old form with macros attached to it?

Use a brand new form and only put this one line of code in the Form Open
event.
You have to use an Event procedure, not a macro.

--
Joe Fallon
Access MVP



"Martin Tudge" <(E-Mail Removed)> wrote in message
news:0b7601c37e83$4ac536c0$(E-Mail Removed)...
> Hi Joe
> Did what you said and got an error message saying 'The
> macro(or its macro group) doesn't exist,'
> Do you think its because I am using access 97 on a windows
> xp pc?
> Regards
> Martin
> >-----Original Message-----
> >Paste these 3 functions into a Module means you copy and

> paste the code into
> >a module and then save the module using a name like

> module1.
> >
> >Then you go to a form and edit it.
> >In the form open event you write this code:
> >
> >PlaySound ("SETUP0.WAV")
> >
> >Then you run the form.
> >The sound plays when the form opens.
> >--
> >Joe Fallon
> >Access MVP
> >
> >
> >
> >"Martin" <(E-Mail Removed)> wrote in message
> >news:01eb01c37e0e$d688d740$(E-Mail Removed)...
> >> Thanks for that, but I am still having trouble.
> >> The sound file I am trying to play is called SETUP0.WAV
> >> and is in the same folder as the database.
> >> Please break this down for me as it is really

> complicated.
> >> Cheers.
> >>
> >> >-----Original Message-----
> >> >These are the 3 functions that I use to play wav files.
> >> >I CALL it in the form open event like this:
> >> >
> >> >PlaySound ("The Microsoft Sound.wav")
> >> >
> >> >Paste these 3 functions into a Module:
> >> >Declare Function apisndPlaySound Lib "winmm"
> >> Alias "sndPlaySoundA" (ByVal
> >> >filename As String, ByVal snd_async As Long) As Long
> >> >Declare Function waveOutGetNumDevs Lib "winmm.dll" ()

> As
> >> Long
> >> >
> >> >
> >> >Public Function PlaySound(msound)
> >> > Dim XX%
> >> > Dim rtn As Integer
> >> > rtn = waveOutGetNumDevs() 'check for a sound card in
> >> the machine
> >> > If rtn = 1 Then 'a sound card exists
> >> > XX% = apisndPlaySound(msound, 1) 'play mmwave sound
> >> > Else ' no sound card was found
> >> > End If
> >> >
> >> > 'If XX% = 0 Then MsgBox ("The Sound Did Not Play!
> >> Because you don't have a
> >> >sound card.")
> >> >End Function
> >> >
> >> >--
> >> >Joe Fallon
> >> >Access MVP
> >> >
> >> >
> >> >
> >> >"Martin Tudge" <(E-Mail Removed)> wrote in message
> >> >news:0c8d01c37dbb$2370b090$(E-Mail Removed)...
> >> >> Hi All
> >> >> I have created a module called 'Soundthings' to play

> a
> >> >> sound within Access.
> >> >> Beliow is the procedures I have put into the module.
> >> >> The only issue now is how do i call up the procedure
> >> >> below to play the sound.
> >> >>
> >> >> Hope someone can help.
> >> >> Regards
> >> >> Martin
> >> >> ________________________________________________
> >> >> Option Compare Database
> >> >> Option Explicit
> >> >>
> >> >> Declare Function sndPlaySound Lib "Winmm.dll"
> >> >> Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
> >> >> ByVal uFlags As Long) As Long
> >> >> Public Const KEY_RETURN = &HD
> >> >> Public Const SND_SYNC = &H0
> >> >> Public Const SND_ASYNC = &H1
> >> >> Public Const SND_NODEFAULT = &H2
> >> >> Public Const SND_LOOP = &H8
> >> >> Public Const SND_NOSTOP = &H10
> >> >>
> >> >> Public Sub PlaySound(pFile As String)
> >> >>
> >> >> sndPlaySound pFile, SND_SYNC
> >> >> End Sub
> >> >>
> >> >> Public Sub PlayIntro()
> >> >> Dim s As String
> >> >> s = DBEngine(0)(0).Name
> >> >> While Right$(s, 1) <> "\": s = Left$(s, Len(s) - 1):
> >> Wend
> >> >> s = s & "SETUP0.WAV"
> >> >>
> >> >> PlaySound s
> >> >>
> >> >> End Sub
> >> >>
> >> >
> >> >
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a module from another module Scott Bass Microsoft Excel Programming 5 26th Feb 2010 03:07 PM
Problem calling Error Handler in Standard Module from Form Module =?Utf-8?B?Sm9obiBE?= Microsoft Access Form Coding 2 19th Apr 2007 02:26 AM
calling another module from within module =?Utf-8?B?cmlja19tYw==?= Microsoft Excel Programming 2 9th Feb 2007 07:19 PM
Calling worksheet module from other module. Michael Malinsky Microsoft Excel Programming 2 14th Dec 2005 08:47 PM
module calling another module SharonInGa Microsoft Access VBA Modules 2 23rd Aug 2004 05:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.