PC Review


Reply
Thread Tools Rate Thread

Combo control to execute code BEFORE change - please help

 
 
davidnicel@googlemail.com
Guest
Posts: n/a
 
      12th Mar 2008
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
 
Reply With Quote
 
 
 
 
michael.beckinsale
Guest
Posts: n/a
 
      12th Mar 2008
Hi David,

If you use the ComboBox_Change event the macro will only be triggered
whenever the selection is changed.

HTH

Michael
 
Reply With Quote
 
davidnicel@googlemail.com
Guest
Posts: n/a
 
      12th Mar 2008
On 12 Mar, 11:06, "michael.beckinsale"
<michael.beckins...@ntlworld.com> wrote:
> Hi David,
>
> If you use the ComboBox_Change event the macro will only be triggered
> whenever the selection is changed.
>
> HTH
>
> Michael


Yes. I don't want to do that. I want to trigger the macro BEFORE the
selection is changed. I.e. As soon as the user clicks on the drop
down box.
 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      12th Mar 2008
Combo boxes have an Enter event which fires when you first enter it.
Does that work?

Private Sub ComboBox1_Enter()
MsgBox "Entered combo box"
End Sub


--JP

On Mar 12, 7:08*am, davidni...@googlemail.com wrote:
> On 12 Mar, 11:06, "michael.beckinsale"
>
> <michael.beckins...@ntlworld.com> wrote:
> > Hi David,

>
> > If you use the ComboBox_Change event the macro will only be triggered
> > whenever the selection is changed.

>
> > HTH

>
> > Michael

>
> Yes. *I don't want to do that. *I want to trigger the macro BEFORE the
> selection is changed. *I.e. *As soon as the user clicks on the drop
> down box.


 
Reply With Quote
 
davidnicel@googlemail.com
Guest
Posts: n/a
 
      12th Mar 2008
Thanks JP.

I don't have that event for some reason. Is it because my combo is on
a worksheet and not on a userform?

Kind regards,

David
 
Reply With Quote
 
davidnicel@googlemail.com
Guest
Posts: n/a
 
      12th Mar 2008
On 12 Mar, 11:20, davidni...@googlemail.com wrote:
> Thanks JP.
>
> I don't have that event for some reason. *Is it because my combo is on
> a worksheet and not on a userform?
>
> Kind regards,
>
> David


I tested it and yes the Enter event is only on userforms.
Unfortunately, I need the combo on the worksheet itself.

Kind regards,

David
 
Reply With Quote
 
davidnicel@googlemail.com
Guest
Posts: n/a
 
      12th Mar 2008
Anyone else got any suggestions?

Your help is much appreciated.

David
 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      12th Mar 2008
well you can't do anything about the forms control when its on a spreadsheet
- though after the event can obviously be done

If you us ethe ActiveX control, then the GotFocus event is fired when the
combo is selected, and you can encode this as you want

"(E-Mail Removed)" wrote:

> Anyone else got any suggestions?
>
> Your help is much appreciated.
>
> David
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute code before a control is "unloaded/closed" BobRoyAce Microsoft Dot NET Framework Forms 2 19th Jun 2006 05:55 PM
combo box on change code =?Utf-8?B?ZnJlbmRhYnJlbmRhMQ==?= Microsoft Excel Misc 0 10th Apr 2006 04:21 PM
change control to combo box? =?Utf-8?B?S2V2aW4=?= Microsoft Access Forms 1 29th Nov 2005 10:35 PM
execute code in one worksheet when change occurs in another suzetter Microsoft Excel Programming 6 16th Jun 2005 06:37 PM
Passing Control object to another code to 'Execute' =?Utf-8?B?R2FyeUc=?= Microsoft Access Form Coding 1 24th Oct 2004 04:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:53 PM.