View Full Version : Solved: ComboBox won't respond to repeat of previous selection
xltrader100
04-25-2009, 02:08 PM
I'm using the Click Event of the ComboBox, but it acts like it's triggering on the Change Event. So if I select Item 1 on the drop down menu, then I can't select it again unless I first select away from Item 1 and then back to it. Is there any way to make it respond more like a real Click Event?
Kenneth Hobs
04-25-2009, 05:04 PM
Maybe the Enter event would be a better fit.
xltrader100
04-25-2009, 06:02 PM
Actually, I've tried just about every event available. I wonder why they bothered to provide both a Click and a Change event if they were going to make them both work like Change events.
Kenneth Hobs
04-25-2009, 06:46 PM
The dropbuttonclick might be a bit better for you.
xltrader100
04-25-2009, 06:52 PM
Nope. That was an early candidate, but no go.
Kenneth Hobs
04-25-2009, 06:59 PM
You probably need to state your goals rather than solution routes that you want to pursue.
Most people care about the change event. Once changed, I am not sure why anything should happen if it is not changed.
xltrader100
04-25-2009, 08:28 PM
My goal, as stated in the question, is to be able to select the same item twice in succession from a drop down menu in a ComboBox.
Aussiebear
04-25-2009, 09:06 PM
What properties are selected in the combobox?
xltrader100
04-25-2009, 10:13 PM
Private Sub ComboBox1_Click()
If ComboBox1.ListIndex = 1 Then Beep
End Sub
If I select Item2 then I get the beep, but it I select it again then I don't.
Aussiebear
04-26-2009, 01:18 AM
No, I mean the properties of the combobox when you designed it.
xltrader100
04-26-2009, 07:30 AM
I'm attaching a screen shot of the Properties Window for the ComboBox.
mikerickson
04-26-2009, 08:07 AM
Perhaps this will work for you
Private Sub ComboBox1_DropButtonClick()
Static DropIsDown As Boolean
If DropIsDown Then
MsgBox "An item has been clicked"
Rem your routine
End If
DropIsDown = Not (DropIsDown)
End Sub
xltrader100
04-26-2009, 08:46 AM
Thanks, Mike. That works great.
xltrader100
04-26-2009, 09:32 AM
But, I don't really understand how it works. When Excel encounters the statement
Static DropIsDown As Boolean
doesn't this re-create the variable DropIsDown and initialize it as False? So how is the IF statement finding it to be True?
mikerickson
04-26-2009, 05:56 PM
The first time it encounters a Static statement, it initializes the variable (as False in this case). Thereafter, the value of the variable doesnot change between runnings of the sub.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.