Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Problem with sub..._Change

I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Problem with sub..._Change

How about the combo's DropButtonClick event. It only gets loaded then when
someone goes to use it.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Problem with sub..._Change

I'm sure there are a couple of ways to fix the problem, here's one
way...
Try declaring a public variable where your main code is running and
giving you the problem, for example:


Dim x as integer ' outside of your main code
Sub yourmaincode()
x = 100

the rest of your code

x = 0
End Sub

Then in your ComboBoxgroupW_Change code:

Private Sub ComboBoxgroupW_Change()
If x = 100 Then Exit Sub
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

Hope this helps you

Sandy

Jacob wrote:
I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Problem with sub..._Change

I'll give that a try. Thanks!


Bob Phillips wrote:
How about the combo's DropButtonClick event. It only gets loaded then when
someone goes to use it.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Problem with sub..._Change

Thanks Sandy. that is what I have done right now and it's working. I
just feel like it's a roundabout way of doing things. I guess if it
works it works.


Sandy wrote:
I'm sure there are a couple of ways to fix the problem, here's one
way...
Try declaring a public variable where your main code is running and
giving you the problem, for example:


Dim x as integer ' outside of your main code
Sub yourmaincode()
x = 100

the rest of your code

x = 0
End Sub

Then in your ComboBoxgroupW_Change code:

Private Sub ComboBoxgroupW_Change()
If x = 100 Then Exit Sub
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

Hope this helps you

Sandy

Jacob wrote:
I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Problem with sub..._Change

I hear ya, but sometimes the simplest routes work the best. Just keep
debugging and looking for the places that fire the change event and see
if you can't tweek the code so that it will only fire when you'd like
it to update the ComboBox.

Good luck

Sandy



Jacob wrote:
Thanks Sandy. that is what I have done right now and it's working. I
just feel like it's a roundabout way of doing things. I guess if it
works it works.


Sandy wrote:
I'm sure there are a couple of ways to fix the problem, here's one
way...
Try declaring a public variable where your main code is running and
giving you the problem, for example:


Dim x as integer ' outside of your main code
Sub yourmaincode()
x = 100

the rest of your code

x = 0
End Sub

Then in your ComboBoxgroupW_Change code:

Private Sub ComboBoxgroupW_Change()
If x = 100 Then Exit Sub
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

Hope this helps you

Sandy

Jacob wrote:
I use a sub to update the options in a listbox based on the selection
of a combobox. I have it set to update when the combobox changes:

Private Sub ComboBoxgroupW_Change()
With UserFormDesign
.ListBoxW.RowSource = .ComboBoxgroupW.Value
End With
End Sub

this is causing problems when the main program is running because
apparently it updates as the main function iterates, and this statement
assigns bad input to rowsource when the function has not completed
running. Is there a better option to use than "Change." Or is there a
way to disable this sub while the program is running? thanks


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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
Why _Change(ByVal Target As Range) Jim at Eagle Excel Programming 4 May 11th 05 07:36 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 12:09 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"