Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo control to execute code BEFORE change - please help
Hello,
First timer here :). This issue has been drving me up the wall and after traweling the Internet I am no wiser. I want to execute some code when the user clicks on a combo box, before they make a selection. E.g. "Do you want to save changes? Yes/ No." Yes runs code (a), No runs code (b). I have tried using the event "DropButtonClick". It works when the user first clicks on the drop button. However, when the user makes a selection, it executes for a second time. Most annoying! Private Sub cmbo_project_dropbuttonclick() Dim Res As Variant Res = MsgBox("Do you want to save changes?", vbYesNo, "Save Changes?") If Res = vbYes Then 'code (a) Else 'code (b) End If End Sub I have tried using the event "MouseDown" and entering the X & Y coordinate of the drop down arrow, so that the code is only run if the arrow is clicked. This worked, however the combo box ignored whatever selection was made. Most annoying! Private Sub cmbo_project_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If 110.25 <= X And X <= Me.cmbo_project.Width Then Dim Res As Variant Res = MsgBox("Do you want to save changes?", vbYesNo, "Save Changes?") If Res = vbYes Then 'copyValueScanData Else 'resetValueScanFormulas End If End If End Sub Can you please help me with either of these approaches or suggest another one. I thought it was be relatively simple to execute code as soon as a combo box is selected, am I missing something? You're help is much appreciated, Kind regards, David |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change font in a forms control combo box | Excel Discussion (Misc queries) | |||
what is code to activate a combo box in control toolbox | Excel Discussion (Misc queries) | |||
combo box on change code | Excel Discussion (Misc queries) | |||
execute code in one worksheet when change occurs in another | Excel Programming | |||
No change event on control toolbox combo box when selection is the same? | Excel Programming |