View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] davidnicel@googlemail.com is offline
external usenet poster
 
Posts: 5
Default 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