Events For UserForm Controls At Run-Time

  • Hi,


    Using VBA in Excel 2003.


    I've created a userform with a set of dynamic controls (i.e. the combo boxes are created at run time).
    I've created a class module to handle events on the combo boxes & this works fine with the _Change event but doesn't work with the _AfterUpdate event.
    In examples on the web, the only events that seem to be given are _Change and _Click.


    My question is: can I get the _AfterUpdate event to work with these dynamic controls?


    I'm happy to post my code if you need it, but as I said it works fine with _Change event, just not _AfterUpdate

  • Re: Events for dynamic controls


    Thanks for the prompt reply.


    Here is the workbook. Hit the command button on Sheet1 to run the form. You will notice that if you change the combo boxes to 'Manual' then a further text box appears


    Now, in the class module, change the _Click to _AfterUpdate


    When you re-run the macro, changing the combo box does nothing


    Thanks for your help


    Edit:
    PS Before anyone asks why I'm not just using a static form - my real workbook is a bit more complicated & the number of 'Areas' comes from a range in the workbook, which can vary
    PPS I was wondering if there was a more general answer on the _AfterUpdate & other events (apart from _Change and _Click). After a bit of thinking, I think I can get away with just the _Click event but I'm just interested to know why _AfterUpdate doesn't seem to work & if there's a way round this

  • Re: Events for dynamic controls


    The Exit, Enter, BeforeUpdate, and AfterUpdate events are sourced by the control object which is a generic interface within MSForms that is dispatched on all MSForms controls including the combobox. You will not have access to these events and I have yet to see a workaround.


    Place this in your custom class


    Public WithEvents c As Control


    The events are listed but you will not be able to use them...

  • Re: Events For UserForm Controls At Run-Time


    Hi,


    I need the code which you wrote for events on the combo box change which is created dynamically.
    I want to create Combo Boxes dynamically and when we change the combo box list item, the other combo box needs to be enabled or disabled.
    So can you please provide the code.
    Thank you.


    Raghu

  • Re: Events For UserForm Controls At Run-Time


    This thread is 5 years old...


    Please start your own thread, give it a title that briefly summarises your issue and explain your problem fully.


    If you think this, or any other thread, can help clarify your issue you can include a link to it by copying the URL from your address bar of your browser, and pasting into your message.