multiple command buttons

nitda1

New member
Local time
Today, 22:27
Joined
Aug 11, 2008
Messages
6
Good evening. can any body enlighten a beginning with the following. Is there a way to have two or more command buttons on a form each which will play the same wav file each time.
i.e.
command button 1 will always play tune 1
command button 2 will always play tune 2
command button 3 will always play tune 3

without have to change anything between using any of the command buttons.

I have managed to get one button to play a wav file.

Thank you in advance.
 
Show us the code you use to play tune 1 at the moment.
 
Hi I have been using the following code

Option Compare Database
Option Explicit

Declare Function PlayWave Lib "winmm.dll" _
Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Function PlayWav()

'Change the file path of the wav file as needed.
Call PlayWave("H:\My Databases\RECIPES\RECIPE DATABASE INSTRUCTIONS\AUDIO IP 1 GENERAL.wav", 0&, &H1 Or &H20000)

End Function

I thenk have a macro which triggers the function with a RunCode command

However I have found a way of solving my problems. I have done this by giving each command button a different function name. (i.e Playwave ()
paly2wave (), play3wave ()etc. I find that this works albeit alittle cumbersome.

I there wish to go with this but thank you all for you interest and assistance

Regards

Martin Davis (nitda1)
 
As an FYI, an alternative would have been a single function that accepted a parameter, let's say a number. You'd associate a different song with each number (I'd use a table to keep it flexible), then simply call the function with the appropriate number from each button:

Call PlayWave(1)
 
Than you very much for you assistance. I have adopted your solution as opposed to the one I worked ou for myself since your method has more flexiblity. Thank you:)
 

Users who are viewing this thread

Back
Top Bottom