Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Events firing willy nilly

[Excel2000]
I have a form with a number of comboboxes and listboxes on it.
Some of these controls change the values of other controls, causing their
events to trigger. I want to stop this in some cases. Has anyone got any
suggestions?

For example, cmbName is changed, and this changes everything else including
cmbType.
But cmbType has a macro that I only want to run when cmbType is manually
changed, but not when its value is changed by another event.

Is it possible to achieve this?

TIA
Darren



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Events firing willy nilly

You would probably need to set a global flag to determine how the control is
being changed. It could get pretty cumbersome with multiple controls. Here's
some untested pseudocode:

Dim fSwitch As Boolean

Sub cmbName_Change()
fSwitch = True
'make changes to cmbType
fSwitch = False
End Sub

Sub cmbType_Change()
If fSwitch = True Then Exit Sub
'your code here
End Sub

You get the idea.

--

Vasant







"Darren Hill" wrote in message
...
[Excel2000]
I have a form with a number of comboboxes and listboxes on it.
Some of these controls change the values of other controls, causing their
events to trigger. I want to stop this in some cases. Has anyone got any
suggestions?

For example, cmbName is changed, and this changes everything else

including
cmbType.
But cmbType has a macro that I only want to run when cmbType is manually
changed, but not when its value is changed by another event.

Is it possible to achieve this?

TIA
Darren





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Events firing willy nilly

Darren,

I don't know of any "disable control events" parameter.
One way is to have a global Boolean variable which tells other events
whether something's already going on.

eg.

Private i As Long
Private blnExecuting As Boolean

Private Sub TextBox1_Change()
If blnExecuting Then Exit Sub
blnExecuting = True
i = i + 1
TextBox2.Text = Left(TextBox1.Text, 1) & i
blnExecuting = False
End Sub

Private Sub TextBox2_Change()
If blnExecuting Then Exit Sub
blnExecuting = True
i = i + 1
TextBox1.Text = Left(TextBox2.Text, 1) & i
blnExecuting = False
End Sub


Rob


"Darren Hill" wrote in message
...
[Excel2000]
I have a form with a number of comboboxes and listboxes on it.
Some of these controls change the values of other controls, causing their
events to trigger. I want to stop this in some cases. Has anyone got any
suggestions?

For example, cmbName is changed, and this changes everything else

including
cmbType.
But cmbType has a macro that I only want to run when cmbType is manually
changed, but not when its value is changed by another event.

Is it possible to achieve this?

TIA
Darren





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Events firing willy nilly

Thanks Rob and Vasant, I'll try that.

--
Darren


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Events firing willy nilly

Update: thanks again, Vasant and Rob. I've got the global variable method
working - whew!

Darren


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to prevent BeforeCloseEvent firing more than once. Daffo Excel Discussion (Misc queries) 3 October 16th 06 02:32 PM
How can I test if a Macro if firing? ZZBC Excel Worksheet Functions 6 January 31st 06 03:09 AM
events? [email protected] Excel Discussion (Misc queries) 1 September 14th 05 03:26 PM
Workbook.Open Event Procedure not firing Gordon Rodman Excel Programming 1 October 17th 03 05:03 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"