Posts by RhinoT

    Re: Userform Initialize vs Userform Show


    The problem is not with your use of Userform_Initialize() that is the correct format. The problem is most likely within the code you have WITHIN Userform_Initialize()


    When the commandbutton in UserForm4 is clicked it calls


    UserForm2.Show - which does the following things
    - Check To See If UserForm2 has already been loaded
    - If Yes Then Display It On The Screen
    - If No Load Userform 2 (Which calls UserForm_Initialize()) and then display it



    Having UserForm_Initialize() in the module for userform 2 is what you want to do so it calls code when UserForm2 is loaded for the first time.


    The problem is that you needed to troubleshoot the error that was occuring when UserForm_Initialize() is called rather than rename it.


    The error is most likely occuring because of all of your code right here:


    TextShares, TextPrice, TextTicker are presumably text fields on UserForm2 correct? In the UserForm_Initialize procedure the form is just being loaded which means subcomponents like TextShares haven't been initialized yet. If TextShares hasn't been initialized you can't set it's members like .Value.


    To change these values like TextShares.Value you have to wait till they have been loaded (initialized has completed).


    Instead of using UserForm_Initialize you want to use UserForm_Activate (activate is called after all of the form and its subcomponents have been initialized).