I have a OLE object that is a wav file and it plays whenever a form is opened. The only catch is that I need it to stop playing when the form is closed. Right now I am having to press the 'esc' key. I've tried using sendkeys, but it doesn't work. Any ideas? - Private Sub Form_Load()
-
Me.txtoffer.SetFocus
-
phone.Action = acOLEActivate
-
End Sub
-
-
Private Sub Form_Timer()
-
Me.TimerInterval = 0
-
thinking.Action = acOLEActivate
-
End Sub
Thanks in advance!
14 4462 NeoPa 32,556
Recognized Expert Moderator MVP
Are you asking how to stop your sound from continuing, or are you asking how the code can run when the form is closed?
ChipR 1,287
Recognized Expert Top Contributor
You can always put a Close button on your form.
NeoPa 32,556
Recognized Expert Moderator MVP
I always recommend using the Form_Close() event procedure, in place of any specific Close button, to handle closing logic. This certainly doesn't mean not to provide one, simply that the only code in there should be :
This way all methods of closing are equally well captured.
I apologize for not correctly organizing my post...its been a while.
here is how i am closing it. To answer your question NeoPa i am wanting to stop the audio file after it has played and when the form closes. - DoCmd.OpenForm "SwitchBoard" (this is actually minimized)
-
DoCmd.Close acForm, "Dond"
This is called when the user clicks a button
NeoPa 32,556
Recognized Expert Moderator MVP @Jollywg
Fair enough. That makes sense. @Jollywg
You don't include the wrappings so it's impossible to tell which event it is within. I suspect (from what you say) that it is within the Click event procedure of a CommandButton. It would be nice to be sure, especially as I've just posted explaining why closing forms code should never be held there. @Jollywg
Unfortunately, that doesn't actually answer my question.
Here it is again :
Are you asking how to stop your sound from continuing, or are you asking how the code can run when the form is closed?
If that's not clear, then I'm asking if you need to know how to code it to stop the noise, or where you would need to put that code (assuming you already have it) to ensure it's run when the form is closed.
I apologize for being unclear, but hopefully we can start to solve the issue...below is all of my code for the form. I've put notes out to the side to give a little more detail as to what is going on. I'm needing to stop the sound when the form is closed. I have no idea as to how to do this, but I would imagine that the code would be placed in the form_colse() or in the NoDeal_Click(). -
Private Sub Form_Load()
-
Me.txtoffer.SetFocus
-
phone.Action = acOLEActivate 'not the sound i'm wanting to stop. only lasts 5 sec)
-
End Sub
-
-
Private Sub Form_Timer()
-
thinking.Action = acOLEActivate 'sound is a rather long wav file that i need to stop if the user closes the form
-
End Sub
-
-
Private Sub NoDeal_Click()
-
DoCmd.OpenForm "SwitchBoard"
-
DoCmd.Close acForm, "Dond"
-
End Sub
-
Thank you for your patience
Jollywg
NeoPa 32,556
Recognized Expert Moderator MVP @Jollywg
I wish it were that easy. I needed to know which you were after because I know I can't help with the code to stop the sound. Only with where best to put it (In Form_Close() as you quite correctly say).
There is nothing in your posted code that tells me what type of object it is that you call thinking. I'm sure it's OLE related (not an area I'm strong in I'm afraid), but beyond that I have no clues. Certainly, if I can help at all here, it would be to advise searching for information related to that OLE object type. It may be (unless you know otherwise) that stopping the sound is not even supported. I don't know.
If you can post what you know about the object (Remember, the class name alone may not be enough) then I can certainly attempt to have a look around for you, but I can't promise anything. As I say, this is new territory for me too.
Sorry I havn't responded...been out of town. I'm absolutely no good at OLE either, all I know is that its a wav object. Is there another way to play a sound and stop it in Access?
NeoPa 32,556
Recognized Expert Moderator MVP
I know of no way, but I've put out a call for help on the WAV object. Let's see what appears.
I appreciate it, thanks NeoPa!
Delerna 1,134
Recognized Expert Top Contributor
Not my strong point either but lets see if I can offer something of value.
Somewhere in your code you are creating the "Thinking" object....right?
something like -
Dim Thinking as Control
-
...
-
Set Thinking=blah blah blah
-
You need to have done something like that in order to use it in your forms timer event. -
Private Sub Form_Timer()
-
thinking.Action = acOLEActivate
-
End Sub
-
which starts the sound playing
So I am wondering if you destroy the thinking object in the form close event, then that might stop the sound.
Something like this -
Private Sub Form_Close()
-
set thinking=nothing
-
End Sub
-
You might need to add some code that checks if thinking still exists
before you destroy it.
If that dosn't work then I would imagine you will need something like -
Private Sub Form_Close()
-
thinking.Action = acOLEDeActivate
-
End Sub
-
I don't know if acOLEDeActivate is correct or not, I will let you find the
constant that does the opposite of acOLEActivate.
I would imagine a search in Google would find thousands of matches
I hope this helps.
Delerna 1,134
Recognized Expert Top Contributor
Actually, you got my interrest peaked.
I just did a quick search and found a potential candidate
acOLEClose
I've tried the acOLEClose and it unfortunately doesnt work, but I will give your previous post a try.
NeoPa 32,556
Recognized Expert Moderator MVP
JollyWg,
It would be helpful for anyone trying to research your problem if you posted both the code that declares these objects and the code that sets them up. Otherwise we're all trying to work with our hands tied behind our backs.
I referred to this earlier if you remember (post #8).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bijay Kumar |
last post by:
Hi Guys,
I was going through the source code of Object.cs in rotor. What I found is
Equals() implemented as follows:
public extern virtual bool Equals(Object obj);
What I don't...
|
by: Daniel |
last post by:
Hello =)
I have an object which contains a method that should execute every x ms. I
can use setInterval inside the object construct like this -
self.setInterval('ObjectName.methodName()',...
|
by: Keith Rowe |
last post by:
Hello,
I am trying to reference a Shockwave Flash Object on a vb code behind page
in an ASP.NET project and I receive the following error:
Guid should contain 32 digits with 4 dashes...
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in...
|
by: Steven T. Hatton |
last post by:
This may seem like such a simple question, I should be embarrassed to ask
it. The FAQ says an object is "A region of storage with associated
semantics." OK, what exactly is meant by "associated...
| |
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have...
|
by: Bijay Kumar |
last post by:
Hi Guys,
I was going through the source code of Object class (Object.cs in rotor). What I found is
Equals() implemented as follows:
public extern virtual bool Equals(Object obj);
What...
|
by: yb |
last post by:
Hi,
Is there a standard for the global 'window' object in browsers? For
example, it supports methods such as setInterval and clearInterval, and
several others.
I know that w3c standardized...
|
by: User1014 |
last post by:
A global variable is really just a property of the "Global Object", so
what does that make a function defined in the global context? A method
of the Global Object?
...
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
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,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |