473,473 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

OLE object wav

158 New Member
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?
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.txtoffer.SetFocus
  3. phone.Action = acOLEActivate
  4. End Sub
  5.  
  6. Private Sub Form_Timer()
  7. Me.TimerInterval = 0
  8. thinking.Action = acOLEActivate
  9. End Sub
Thanks in advance!
Oct 7 '09 #1
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?
Oct 7 '09 #2
ChipR
1,287 Recognized Expert Top Contributor
You can always put a Close button on your form.
Oct 7 '09 #3
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 :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.Close
This way all methods of closing are equally well captured.
Oct 7 '09 #4
Jollywg
158 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "SwitchBoard"     (this is actually minimized)
  2. DoCmd.Close acForm, "Dond"
This is called when the user clicks a button
Oct 7 '09 #5
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.
Oct 7 '09 #6
Jollywg
158 New Member
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().

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.txtoffer.SetFocus
  3. phone.Action = acOLEActivate    'not the sound i'm wanting to stop. only lasts 5 sec)
  4. End Sub
  5.  
  6. Private Sub Form_Timer()
  7. thinking.Action = acOLEActivate  'sound is a rather long wav file that i need to stop if the user closes the form
  8. End Sub
  9.  
  10. Private Sub NoDeal_Click()
  11. DoCmd.OpenForm "SwitchBoard"
  12. DoCmd.Close acForm, "Dond"
  13. End Sub
  14.  
Thank you for your patience
Jollywg
Oct 8 '09 #7
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.
Oct 8 '09 #8
Jollywg
158 New Member
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?
Oct 11 '09 #9
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.
Oct 11 '09 #10
Jollywg
158 New Member
I appreciate it, thanks NeoPa!
Oct 12 '09 #11
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
Expand|Select|Wrap|Line Numbers
  1. Dim Thinking as Control
  2. ...
  3. Set Thinking=blah blah blah
  4.  
You need to have done something like that in order to use it in your forms timer event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer() 
  2.    thinking.Action = acOLEActivate  
  3. End Sub 
  4.  
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
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close() 
  2.    set thinking=nothing
  3. End Sub 
  4.  
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
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close() 
  2.    thinking.Action = acOLEDeActivate  
  3. End Sub 
  4.  
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.
Oct 16 '09 #12
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
Oct 16 '09 #13
Jollywg
158 New Member
I've tried the acOLEClose and it unfortunately doesnt work, but I will give your previous post a try.
Oct 16 '09 #14
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).
Oct 16 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
28
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()',...
9
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...
11
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...
44
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...
16
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...
0
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...
26
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...
3
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? ...
2
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);
0
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...
0
marktang
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.