Dynamic created combo-box working on one form but not other, class module issue?

  • Thank you for having a read:


    I have two forms with dynamically created comboboxes attempting to reference the same class module.


    The first works as expected with the relevant code as follows:



    Class module code here:


    On another form in the same workbook I am attempting to achieve a similar result using:


    The reactions code as seen in the class module "if reactions.visible" works fine and when I change those comboboxes the code in the if statement of the class module works and I get the debug.print of both "HeLio" and "Hi"... however nothing from the class code runs when I change the comboboxes on the second form using the not working code.


    Any insight and improvement to the existing code would be appreciated.


    Regards

    Justin

  • Hi Roy, I was hoping it would be obvious that I was missing something from the code, I have attached a workbook.


    From the Sheet labelled "FRONT" select "SHOW DIRECTORY"


    Click on "REACHBACK" under select client.


    Select "VIEW REACTIONS" then click the big green button.


    At the bottom of the form that displays is the synthesis pathway in a list box, select it. Then select one of the pathways that appear in the listbox that appears along side.


    Click on the Frame in the background (should be an image background), then select one of the comboboxes that appear and it should update the caption on the respective button below it. This is the working code, it uses the "REACTIONS" form, and the code is linked to the LBSELECT listbox on this form.


    Now open the directory and select the "LAB TOOLS" client, then "STANDARDS PREPARATION" and click the green button.


    On the multipage go to "MultiComponent Mix from Stock" and use the spin button a few times to increase the number in the label alongside. Click on the label to create the dynamic textboxes and comboboxes then make a selection from the combobox. This is the code that is not working, it is linked to the UFSTDRDS form and code is in the LMCMCOUNT label.


    I know there are errors in the code elsewhere as well, this is still a first draft and I am working through and learning as I go. Any pointers much appreciated. At a later date I might pay for some input if it proves fit for purpose.


    If you need me to clarify or highlight anything let me know.


    See later post for correct workbook


    Regards

    Justin

  • Hi Roy,


    I have cut this down to only the class module, the form that has the error and enough information for it to work.


    I ran the dubug compile and it seems to be clear on this one, obviously not something I have done previously... I will have some fun working through that soon.


    Regards
    Justin


    Test.xlsb

  • I haven't looked at your workbook, but the declaration of your collection in the second code is in the wrong place. This line:


    Code
    Dim m_colComboBoxEvents As Collection


    needs to be at the module level. Otherwise, as soon as your routine finishes, the variable is cleared and there are no instances of your class left.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Thank you Rory,


    that has fixed the issue. I just checked the reactions form and the collections are declared at the top of the form code, I just did not translate correctly to the new form. I have been banging my head for days trying to work that out.


    Brilliant Thank you...


    You should have a "Buy Me a Coffee" option somewhere on the site.


    Regards

    Justin

  • I'd rather have gin... :)

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!