Solved

ActiveX Listbox events do not fire

Posted on 2011-02-16
6
686 Views
Last Modified: 2013-11-05
Hi there,

I've got a form in an Excel VBA program that contains listboxes displaying user selections. When these listboxes are emptied, I want to disable a commandbutton on the form to prevent the user from continuing without having selected an item. Correspondingly, I want to enable this commandbutton as soon as something is written to the listbox again. All adding/deleting of items in the listbox is handled by the code.
I thought this was easy to achieve using events, but neither the listbox_change event nor the listbox_afterupdate event fires when an item is added to or removed from the listbox. Why not? What kind of event should I use?

best regards,
Einar
0
Comment
Question by:EISTO
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:FernandoFernandes
Comment Utility
what about the exit event, isn't it firing ?
0
 

Author Comment

by:EISTO
Comment Utility

Hi, Fernando

No, the exit event doesn't fire either

/Einar
0
 
LVL 6

Assisted Solution

by:FernandoFernandes
FernandoFernandes earned 250 total points
Comment Utility
wait...
what's addin stuff to your listbox ? I mean, listbox is populated via code isn't it ? you dpn't need an even for it...
also, only for the sake of checking everything, is the event handler turned on?

Application.EnableEvents = True
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:EISTO
Comment Utility

Fernando,

I could write code in each and every routinge that manipulates the contents of the listbox, but it would be a whole lot easier to write it once and for all in an event handler.
....as far as I know, the application.enableevents property does not affect ActiveX-events. It is only applicable to events of objects inherent to Excel.

/Einar
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 250 total points
Comment Utility
There is no event specifically related to adding an item to a listbox, so I would agree that the code adding the item should call whatever you want triggered.
0
 

Author Closing Comment

by:EISTO
Comment Utility
Thanks guys,

VBA seems to be unable to handle this, so let's close the thread.

/Einar
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now