Duplicating of Message Boxes

  • Thread starter Thread starter Jim May
  • Start date Start date
J

Jim May

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub
 
..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub
 
Thanks Dave. Can you reinterate a bit on what the code is doing here?
I can follow it some, but not all-the-way.
Thanks,
Jim
 
The code just sets a toggle. You turn it on right before you change something
that would cause the _change procedure to fire.

It doesn't stop the event from firing a second time, but that first line says
that if the toggle is on, don't do any of the real code--just get the heck out.

And after you make the change, you turn that toggle off.

Step through it and you'll see that it really does fire twice.
 
Pretty Cool, it's amazing what all you have to consider in doing something
like this.
Thanks, Dave I (much) better understand - by stepping through the code.
 
You can observe a lot just by watching!

<vbg>

Jim said:
Pretty Cool, it's amazing what all you have to consider in doing something
like this.
Thanks, Dave I (much) better understand - by stepping through the code.
 
Back
Top