PC Review


Reply
Thread Tools Rate Thread

combobox change event is running when enable events is false

 
 
=?Utf-8?B?dHlzb3A=?=
Guest
Posts: n/a
 
      24th Jan 2006
I am writing some VBA that changes the value in a control toolbox combobox,
but I don't want it to run the code assigned to changing the combobox ( it
clears it runs some other code and then changes it to a different value). I
therefore disabled enableevents, but it is still doing so. I have even put a
messagebox at the start of the combobox change event code to display the
enableevents status, and getting False back!

Is there anyway to avoid this, as surely the purpose of being able to
disable events is that this shouldn't happen.


I am using excel 2000 if that makes any difference.

Many thanks

 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      24th Jan 2006
Hi Tysop,

Try using a public boolean variable selectively to disable the ComboBox
code.

At the top of a standard module:

Option Explicit

Public blDisable As Boolean

Then, in the sheet module:

'=============>>
Private Sub ComboBox1_Change()
If blDisable Then Exit Sub
'Your code
End Sub
'<<=============

When you need to disable the ComboBox1_Change code, assign a value of True
to the variable.


---
Regards,
Norman


"tysop" <(E-Mail Removed)> wrote in message
news:F29A57C9-7EBD-42F3-8938-(E-Mail Removed)...
>I am writing some VBA that changes the value in a control toolbox combobox,
> but I don't want it to run the code assigned to changing the combobox ( it
> clears it runs some other code and then changes it to a different value).
> I
> therefore disabled enableevents, but it is still doing so. I have even
> put a
> messagebox at the start of the combobox change event code to display the
> enableevents status, and getting False back!
>
> Is there anyway to avoid this, as surely the purpose of being able to
> disable events is that this shouldn't happen.
>
>
> I am using excel 2000 if that makes any difference.
>
> Many thanks
>



 
Reply With Quote
 
=?Utf-8?B?dHlzb3A=?=
Guest
Posts: n/a
 
      24th Jan 2006
I actually had just tried that and it works, but it's just annoying that I
now have to change a boolean and dissable events- I'll probably create a sub
that disables both and call that when i need to.

Many thanks

Tysop

"Norman Jones" wrote:

> Hi Tysop,
>
> Try using a public boolean variable selectively to disable the ComboBox
> code.
>
> At the top of a standard module:
>
> Option Explicit
>
> Public blDisable As Boolean
>
> Then, in the sheet module:
>
> '=============>>
> Private Sub ComboBox1_Change()
> If blDisable Then Exit Sub
> 'Your code
> End Sub
> '<<=============
>
> When you need to disable the ComboBox1_Change code, assign a value of True
> to the variable.
>
>
> ---
> Regards,
> Norman
>
>
> "tysop" <(E-Mail Removed)> wrote in message
> news:F29A57C9-7EBD-42F3-8938-(E-Mail Removed)...
> >I am writing some VBA that changes the value in a control toolbox combobox,
> > but I don't want it to run the code assigned to changing the combobox ( it
> > clears it runs some other code and then changes it to a different value).
> > I
> > therefore disabled enableevents, but it is still doing so. I have even
> > put a
> > messagebox at the start of the combobox change event code to display the
> > enableevents status, and getting False back!
> >
> > Is there anyway to avoid this, as surely the purpose of being able to
> > disable events is that this shouldn't happen.
> >
> >
> > I am using excel 2000 if that makes any difference.
> >
> > Many thanks
> >

>
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      24th Jan 2006
Just for clarification, enableevents is part of the Excel Object model.
MSForms controls are part of the MSForms object model. These controls are
not affected by the EnableEvents setting.

--
Regards,
Tom Ogilvy

"tysop" <(E-Mail Removed)> wrote in message
news:5B5D0B4C-7CBB-4739-A595-(E-Mail Removed)...
> I actually had just tried that and it works, but it's just annoying that I
> now have to change a boolean and dissable events- I'll probably create a

sub
> that disables both and call that when i need to.
>
> Many thanks
>
> Tysop
>
> "Norman Jones" wrote:
>
> > Hi Tysop,
> >
> > Try using a public boolean variable selectively to disable the ComboBox
> > code.
> >
> > At the top of a standard module:
> >
> > Option Explicit
> >
> > Public blDisable As Boolean
> >
> > Then, in the sheet module:
> >
> > '=============>>
> > Private Sub ComboBox1_Change()
> > If blDisable Then Exit Sub
> > 'Your code
> > End Sub
> > '<<=============
> >
> > When you need to disable the ComboBox1_Change code, assign a value of

True
> > to the variable.
> >
> >
> > ---
> > Regards,
> > Norman
> >
> >
> > "tysop" <(E-Mail Removed)> wrote in message
> > news:F29A57C9-7EBD-42F3-8938-(E-Mail Removed)...
> > >I am writing some VBA that changes the value in a control toolbox

combobox,
> > > but I don't want it to run the code assigned to changing the combobox

( it
> > > clears it runs some other code and then changes it to a different

value).
> > > I
> > > therefore disabled enableevents, but it is still doing so. I have

even
> > > put a
> > > messagebox at the start of the combobox change event code to display

the
> > > enableevents status, and getting False back!
> > >
> > > Is there anyway to avoid this, as surely the purpose of being able to
> > > disable events is that this shouldn't happen.
> > >
> > >
> > > I am using excel 2000 if that makes any difference.
> > >
> > > Many thanks
> > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox problem handling SelectedIndexChanged event and keypress events dule Microsoft Dot NET Compact Framework 2 2nd Feb 2007 08:17 AM
Multiple combobox and change events jbrooxie Microsoft Excel Programming 0 4th May 2006 03:17 PM
MsgBox in Enter event causes combobox not to run Change event =?Utf-8?B?UmljaGFyZA==?= Microsoft Excel Programming 0 6th Mar 2006 02:52 PM
How do I change format of text fields when enable=false? =?Utf-8?B?cm9hZCBkb2c=?= Microsoft Access VBA Modules 4 6th Dec 2005 07:09 PM
Change enable=false forecolor Stephen Microsoft VB .NET 4 11th Jan 2005 08:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:41 AM.