ADezii 8,834
Recognized Expert Expert
Most Access Users fail to realize that they can significantly enhance their applications by introducing various sounds (*.WAVs) in response to specific events. The only intrinsic sound that Access can generate is the DoCmd.Beep which is hardly worth the time to mention. You can incorporate sound functionality into your Access applications via a single call to a relatively simple API Function. A couple of arguments to the Function dictate where the sound file (*.WAVs) is located, and how the sound is played. The code below will play the all-too-familiar TaDa.wav once a Record has been successfully saved, and FogHorn.wav if an Error is generated in the Update operation. Carefully follow the steps below which are listed in sequence. 1. Declare the API Function within a Standard Code Module along with its Flags Arguments. - Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
-
-
'The Flags Argument modifies the behavior of sndPlaySound
-
'SND_ASYNC - Sound played asynchronously. Code after the Sound function
-
'will immediately be executed.
-
-
'SND_SYNC - Sound must finish first before further Code is executed
-
'SND_LOOP - Can be combined with SND_ASYNC to create a continuous
-
'Background Loop
-
'iRetValue = sndPlaySound("C:\WAV\MYWAV.WAV", SND_ASYNC + SND_LOOP)
-
'The Sound continues playing until the Program executes another sndPlaySound call.
-
-
-
Public Const SND_ASYNC = &H1
-
Public Const SND_SYNC = &H0
-
Public Const SND_LOOP = &H8
2. Make the Call(s) to the API Function from the appropriate Event(s). - Private Sub Form_AfterUpdate()
-
On Error GoTo Err_Form_AfterUpdate
-
-
Dim iRetValue As Long
-
'Record has been successfully Saved
-
iRetValue = sndPlaySound("C:\Sounds\TaDA.wav", SND_ASYNC)
-
-
Exit_AfterUpdate:
-
Exit Sub
-
-
Err_Form_AfterUpdate:
-
'some type of Error occurred
-
iRetValue = sndPlaySound("C:\Sounds\FogHorn.wav", SND_ASYNC) MsgBox Err.Description, vbExclamation, "Error in Form_AfterUpdate()"
-
Resume Exit_AfterUpdate
-
End Sub
3. The above code can further be improved by first checking to see if the User's System supports the playing of sounds, and if the requested file actually exists. If anyone is interested in viewing either one of these enhancements, please let me know.
10 26152
I'm interesterd in the enhancements - please share!!!
ADezii 8,834
Recognized Expert Expert
I'm interesterd in the enhancements - please share!!!
The 2 enhancements that I had previously referred to are: - See if the User's System is capable of playing .WAV files. This can be accomplished via a simply API Function named waveOutGetNumDe vs() which will retrieve the number of Waveform-Audio Output Devices in the User's System. If it returns 0, then no capability exists to play .WAVs. The Declaration is listed below and its usage will be in the complete code listing.
- Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
- Check and see if the *.WAV actually exists in the specified Path. This can be accomplished via the Dir$() Function. The complete code block is listed below for your reference.
- Dim iRetValue As Long, strSoundPath As String
-
strSoundPath = "C:\Sounds\TaDA.wav"
-
-
If waveOutGetNumDevs() <> 0 Then 'System is capable of playing Sounds
-
If Dir$(strSoundPath, vbNormal) <> "" Then 'Valid Path to .wav file
-
iRetValue = sndPlaySound(strSoundPath, SND_ASYNC)
-
Else
-
''don 't need this - here for demo purposes only. If an empty String
-
'is returned by Dir$, do not make an attempt to play the Sound
-
End If
-
End If
Cool - the training database in my office now plays the theme tune from Team America when anyone presses a button
I thought it'd be funny, no one else does!
ADezii 8,834
Recognized Expert Expert
Cool - the training database in my office now plays the theme tune from Team America when anyone presses a button
I thought it'd be funny, no one else does!
I share your sense of humor also. Databases can be a little cut-N-dry - I'll try anything, including a little sound, to liven them up!
They're all trying to figure out whats going on it's hilarious!
I'm on holiday next week - will fix it when I get back haha
ADezii 8,834
Recognized Expert Expert
They're all trying to figure out whats going on it's hilarious!
I'm on holiday next week - will fix it when I get back haha
I know exactly what you mean. I once created an Inventory System for a Department and once they realized that they could incorporate Sound functionality into the Database, they wanted to use it. On this System, there existed a large number of Lookup Tables to enforce Field Validation. Everytime an incorrect entry was made in a Field, an audible rejection Sound was heard by everyone in the Department. In this case, the use of Sound was not a good thing. It did, however, cut done on Invalid Entries but did nothing for employee morale and didn't make me the most popular person in the area.(LOL).
well, nice idea...hmm, playing sounds in access? im interested with it but, im not knowledgeable bout it...
ADezii 8,834
Recognized Expert Expert
well, nice idea...hmm, playing sounds in access? im interested with it but, im not knowledgeable bout it...
Just follow the guidelines in Post #1 for the basic approach.
Just follow the guidelines in Post #1 for the basic approach.
Hi! Nice topic you got. Where will i encoded the commands in Post #1?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Keyser |
last post by:
On most my pages, I use Javascript to play a sound. It works fine in
Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as
the operating system. However, using WindowsXP as the operating system,
the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when
I try to use the Back button on these pages. Is there some setting in
Windows XP that is causing this or is there something I can add to the
Javascript to...
|
by: Andrew Poulos |
last post by:
As a follow on to the 'fun' I had with IE I'm now trying to play sounds
using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets
clicked MZ says that "audObj.Play is not a function":
window.onload = function() {
var audObj = document.createElement("object");
audObj.setAttribute("id", "objmedia");
audObj.setAttribute("type","audio/x-aiff");
audObj.setAttribute("data","media/aif_sample.aif");
|
by: MLH |
last post by:
Edit, Insert Object & choose Wave Object, the following
OLE object thing gets inserted onto the form...
Microsoft Sound Recorder
Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)
Copyright 1981-2001 Microsoft Corporation
PCM 22.050 kHz, 8 Bit, Mono
If I double-click the icon-looking thing on the form after setting its
.Enabled property to true AND its .Verb property to -2, the Microsoft
|
by: MLH |
last post by:
I have some audio help files that play fine from within Access 97
and Access 2.0. Both are running on a Windows XP box. But I
do not know what program plays the files.
If I click Start, Run and type in c:\MyApp\MyHelp\Help1.wav,
Windows Media Player tries unsuccessfully to play the wav file.
It err's saying ClassFactory cannot supply the requested class.
But WMP has no problem at all playing c:\windows\system32\
ALSNDMGR.WAV. That goes...
|
by: Steph. |
last post by:
Hi !
How can I play "standard system sounds" in C# ?
( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() )
Thanks !
steph.
| |
by: ZikO |
last post by:
Hi.
I'm struggle with playing a wav in Visual Basic. First I wanted to use
My.Computer.Audio.Play() method but I realized it's not working if I want to
have music in background.
I found in internet SoundPlayer Class but unfortunately I can't find it in
my Visual Studio Application. Whenever I try to use it
Dim Player New SoundPlayer ...
|
by: elusified |
last post by:
Hey guys, i'm currently doing a website that required random background music. But now im facing a problem where how can i modify my current script so that it will auto play the next track instead of looping the current track? Im kinda new to this. thanks in advance =)
These are my codes:
var sound1="sounds/2001spce.mid"
var sound2="sounds/20fox.mid"
var sound3="sounds/9010v2.mid"
var sound4="sounds/adam.mid"
var...
|
by: Jake Barnes |
last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching
for "how to play a sound with Javascript". I'm somewhat suprised that
the majority of entries are from the 1990s, and there are almost no
posts from the last 3 years:
http://groups.google.com/group/comp.lang.javascript/search?group=comp.lang.javascript&q=how+to+play+a+sound+with+Javascript&qt_g=Search+this+group
Even after sorting by date, there don't appear any...
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to cut and paste code that MSDN recommends for playing a
simple wav file from inside an embedded file, like presumeably the
'resources' file .resx is. I want to embed the .wav file in a
'resource file' since I don't want the user storing the file on...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |