[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Reset ActiveX ComboBox top entry

New challenge.

I have an Active X combobox where the list is the contents of a list of cells.  I have used ComboBox1.ListIndex = 0 to reset the list to the top entry.  But when I do that it triggers the ComboBox1_Change() sub.

I thought of putting something into the sub to check if I am resetting the list or the user has actually selected something.

Is there a better way to reset the box to the top entry?
0
IBMJunkman
Asked:
IBMJunkman
  • 3
  • 2
1 Solution
 
gowflowCommented:
Do something like this

Application.EnableEvents = False
Sheets("Sheet1").ComboBox1.ListIndex = 0
Application.EnableEvents = True

gowflow
0
 
gowflowCommented:
Sorry misunderstoo your question my previous post does not prevent from going into combobox change. If the user is selecting something he will triger click event and dropdown event first if programatically you reset the to top level then it will triger change.

You can create module level variable say
Dim TopLevel as boolean
and everytime you use
Sheets("Sheet1").ComboBox1.ListIndex = 0
TopLevel = True

and where you do not want the code to run you put somehting like
if Not TopLevel then
/// your usual code in that sub

else
TopLevel= false
endif

gowflow
0
 
Rory ArchibaldCommented:
Note: it needs to be:
TopLevel = True
Sheets("Sheet1").ComboBox1.ListIndex = 0

Open in new window


or the change event will already have fired before you set the variable.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
IBMJunkmanAuthor Commented:
I caught that.  Thanks.
0
 
gowflowCommented:
oops my seeping mind ... rorya just correct !
gowflow
0
 
IBMJunkmanAuthor Commented:
solution worked
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now