how can I play sound (ex: c:\windows.000\chimes.wav) in my project.

  • Thread starter Thread starter Kelvin Nguyen via AccessMonster.com
  • Start date Start date
K

Kelvin Nguyen via AccessMonster.com

I have a acess project that use the bar code scanner, I just want to play
sound for example: chimes.wav when the user scan wrong part_number into a
field.
Please help, thanks
 
in message:
I have a acess project that use the bar code scanner, I just want to play
sound for example: chimes.wav when the user scan wrong part_number into a
field.
Please help, thanks

Hi Kelvin,

Here is a past post of mine on this subject.
Follow this link to Allen Browne's site:

http://allenbrowne.com.au/func-04.html

1. Create a new module and add in the code as instructed

2. Then just add code like this to whatever event you
want. Such as GotFocus or something.

=PlaySound("C:\StarWarsTheme.WAV")

Make sure you include the full path and extension.


There is also code here for doing the same thing:

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

Example usage like so for different sounds for different records:

Let's assume you have a field in the table called PathToSoundFile and you
have a corresponding control on the form bound to that field called
txtPathToSoundFile. The code behind the command button would now
look like this:

' *******Code Start*********
Private Sub cmdPlaySound_Click()
On Error GoTo ErrorPoint

Dim strPath As String

If Len(Nz(Me.txtPathToSoundFile, "")) = 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 = Me.txtPathToSoundFile
fPlayStuff (strPath)
End If

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
' *******Code End*********

This will work with forms in Single or Continuous layout.
You optionally could save the record first if you desire as well.
Hope that helps,
 
Dear Fred,
Thank you very much for your help.
Kelvin
 
Dear Jeff,
Thank you very much for your help.
Kelvin
 
in message:
Dear Jeff,
Thank you very much for your help.

You're welcome Kelvin, glad we could help.
Thanks for checking back with us.

Good luck with your project.
 

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

Back
Top