+ Reply to Thread
Results 1 to 18 of 18

Adding controls to Userform from another Userform

  1. #1
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Adding controls to Userform from another Userform

    Hello Guys,

    I have created a "UserForm 1". It contains texboxes and their buttons. When I click the button I want an "userform 2" to pop up and textboxes should be created in it.

    For example. In "UserForm 1" , I have a text box . If I enter a value = "5" and click the button, I want another "UserForm 2 " to pop up and "5" text boxes should be created in UserForm 2.

    Looking forward for your help.

    Thanks in Advance

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    AdiK,

    How you do this depends greatly on the needs. Will UserForm2 ONLY be invoked by UserForm1? Should UserForm1 go away when UserForm2 loads?

    Assuming yes to those questions:

    The button for userform1 would only need one line:

    Please Login or Register  to view this content.
    then in userform2:

    Please Login or Register  to view this content.
    In userform1 you may want to add some kind of check that there really is a number in Textbox1 before calling up UserForm2
    Last edited by Arkadi; 02-09-2017 at 09:25 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Adding controls to Userform from another Userform

    You will also have to set the VISIBLE property...

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    of the textboxes? They are visible by default

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Adding controls to Userform from another Userform

    My apologies. Other controls (labels, for example) are invisible by default. I just tend to set the Visible property as a matter of course.

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    No worries cytop, it is good practice either way, I should do that.
    I have edited my post to include the suggestion.

  7. #7
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    Thaks a lott guys..
    But the "Userform 1" is still visible after "UserForm 2" is opened. I have used Unload Me command but it doesnt work.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    In the Initialize for form2, did you include the line I had to unload userform1? name must match exactly for it to work of course.... but it works on my end. Userform1 can't unload itself while form2 is up unless form2 is modeless...

  9. #9
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    Got it!! Thank u very much again!

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    Great!
    If you are happy with the result, please remember to mark the thread as solved?

  11. #11
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    I have a problem Arkadi. In the "UserForm 2 ", I have a frame and a multipage setup. When i run the code by clicking the button on "Use form 1", the text box gets created on the "UserForm 2", but hides behind the frame and the multipage. How can i send the frame ad the multipage behind the text box??

  12. #12
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    I have a problem Arkadi. In the "UserForm 2 ", I have a frame and a multipage setup. When i run the code by clicking the button on "Use form 1", the text box gets created on the "UserForm 2", but hides behind the frame and the multipage. How can i send the frame ad the multipage behind the text box??

  13. #13
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    I think what you want then is to put the texboxes in the frame, not the basic form?
    Change:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Where Frame1 is the name of the frame you are referring to.

  14. #14
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    This works Fine. But there is still the Multipage ( Page 1 and Page 2) over the Frame and Similar line of code is not available for multipages.

  15. #15
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    Oh the frame is behind the multipage?

    Try this:

    Pages(0) is the first page, change as needed... and MultiPage1 should match the name of your multipage:

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    10-25-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    47

    Re: Adding controls to Userform from another Userform

    Thanks a ton!! I would like to know how do you figure out the commands? It is actually impossible without the intellisense.

  17. #17
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    For me mostly experience now... but when I was learning (and still often need to remember exact syntax), I used google, often 1 hour of google for 15 minutes of code.
    It gets easier as you practice and learn of course.

  18. #18
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Adding controls to Userform from another Userform

    Please remember to mark the thread as solved if your issue is resolved? Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] A problem with adding and deleting dynamic controls in a userform
    By keaden in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2015, 01:47 PM
  2. [SOLVED] Userform Controls shortcut - close userform by escape key
    By ag273n in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2014, 06:23 PM
  3. Adding more controls than will fit in visible area of userform
    By bberger1985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 11:12 AM
  4. [SOLVED] Adding Controls to a userform Listview
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2012, 07:36 AM
  5. Which controls would be best to use for this Userform?
    By Kr4ftw3rk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-24-2008, 09:50 AM
  6. adding controls to userform at runtime
    By Ouka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2005, 03:11 PM
  7. Adding controls to userform
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2005, 08:06 AM

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