Solved

ActiveX Listbox events do not fire

Posted on 2011-02-16
6
701 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

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

Author Comment

by:EISTO
ID: 34907793

Hi, Fernando

No, the exit event doesn't fire either

/Einar
0
 
LVL 6

Assisted Solution

by:FernandoFernandes
FernandoFernandes earned 250 total points
ID: 34907833
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:EISTO
ID: 34907910

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
ID: 34915022
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
ID: 34915091
Thanks guys,

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

/Einar
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

707 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