+ Reply to Thread
Results 1 to 5 of 5

Same form opened multiple times

  1. #1
    Registered User
    Join Date
    02-13-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Same form opened multiple times

    Hi,

    I am programming a simple database in excel that allows a user to select a part and a material from 2 comboboxes, and then have a userform pop-up and show him the material's properties.

    There is a "masterform", i.e. Form1, where the user makes the selections. There are 11 different SubForms for the different parts.

    Ex.
    Masterform
    User selects a Part from combobox1 (Part_x).
    User selects a Material from combobox2 (Material_y).

    *SubformPart_x pops up filled with the properties associated with selected Material_y.

    What I want, is to keep the "masterform" active so the user can select different materials for comparison. The option ShowModal=False does this perfect.

    Problem
    However, and here is the problem, if the user selects twice the same part, the Subform associated with that part cannot be displayed twice (or more) at the same time.

    The problem is that the different fields in the subform are filled by looking into different sheets in the workbook. I figure that when I select a new material, but for the same part (thus filling the same userform), the different fields are already filled. To make it work, I need to close the subform and then select a material.

    If I select materials from 2 different parts (using two different subforms), there are no problems at all.

    Question
    Is there a way to unload or clear variables from a form, but keep it opened ? What I mean is that when I select a material and the associated subform opens, is it possible to clear the variables filling the different textboxes, but keep the subform opened with the textboxes filled, so that when I select another material (same part), a new subform pops up with the new material properties.

    Ex.
    Masterform
    User selects a Part from combobox1 (Part_x).
    User selects a Material from combobox2 (Material_y).

    *SubformPart_x pops up filled with the properties associated with selected Material_y.

    User selects the same Part from combobox1 (Part_x).
    User selects a new Material from combobox2 (Material_y2).

    *SubformPart_x pops up filled with the properties associated with selected Material_y2, with the previous SubfromPart_x filled with the properties associated with Material_y.

    i.e. There would be 3 userforms opened at the same time : Masterform, SubformPart_x with Material_y properties & SubformPart_x with Material_y2 properties.


    Would the best way to make this work be to create a Public variable that would be changed everytime a user selects a new material ?

    Thanks in advance,
    Alexis

  2. #2
    Registered User
    Join Date
    02-13-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Same form opened multiple times

    From reading more deeply into the subject, I need to create the new subform as a new object in order for it to be considered a different userform.

    Please Login or Register  to view this content.
    Anyone have any other way to do this ?

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Same form opened multiple times

    The example code below creates a new copy of UserForm1 and sets some example properties on the new copy.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-13-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Same form opened multiple times

    Thanks,

    Works beautifully.

    /SOLVED
    Last edited by alsega; 04-11-2012 at 02:52 PM.

  5. #5
    Registered User
    Join Date
    02-13-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Same form opened multiple times

    Problem in the horizon ! And I honestly can't figure it out.

    Please Login or Register  to view this content.
    *The line in bold is where I get the Error 424 message.

    The problem is that when I select "Quarter package" in my combobox1 (cbx1), there program gives me a "Error 424 undefined object". However, I do have a Userform with the name "FormQuarters". And to make it absurd, if I select anything else than an option using that FormQuarters userform, everything works beautifully....

    I'm banging my head on this one, I can't seem to make sense of it...and it was actually working very well until I made some modifications to the FormQuarters userform. However, they were only changes in the form itself (adding textboxes), so I don't see how that could have affected the program.


    Thanks,
    Alexis
    Last edited by alsega; 04-12-2012 at 10:40 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1