+ Reply to Thread
Results 1 to 9 of 9

Combining UserForm Controls

  1. #1
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Unhappy Combining UserForm Controls

    Good Day,

    I am struggling to combine procedures from 3 user forms into 1 user form.

    I have the main form to add and amend data, I have a second user form to search and a 3rd to view.

    I have added the search into userform1 and added the list view from the other form, however I cannot get them to all sync/work with each other.

    I want the search to list the results in the list view and when I click on the list view item it will populate the form.

    Each works fine when on different forms but I cannot figure out how to combine them onto 1 user form?

    I am not an expert and have really been struggling.

    Attached find a copy of my workbook.

    Is anyone able to assist?

    Thank you...
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-07-2018
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    20

    Re: Combining UserForm Controls

    If 'real estate' is the issue, you can store large numbers of controls on a single user form by using the multipage control - that just effectively adds 'pages' to the userform, and you can switch between them by click on a tab.

    Having had a very quick look though, I wonder if you might be experiencing problems because the bulk of your code seems to be stored within each of the actual userforms - you really want to try and avoid that as much as possible, not least because userforms are by default private (class) modules and the code in one is not easily accessible (nor properly accessible) from outside that particular userform. The better approach would be to store the code in standard modules, and then call those functions/subs from the relevant userform (where appropriate). Does that make sense?

  3. #3
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100
    Thank you… unfortunately I have no idea how to do that, I’ve tried the tab thing but it’s been too difficult, I’ve basically built all this code over 2 years taking bits from here and there…

    I don’t suppose you could?

    I’ve tried taking templates of UserForms with tabs and I still can’t get it right so I’ve stuck with what I have as it works. It would be so much better within 1 form.. and the list below with a search would be impressive.

    What do I do? 😭

  4. #4
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: Combining UserForm Controls

    I do understand what you mean by storing it in modules. Thanks and well noted.

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Combining UserForm Controls

    What @Dan_W is recomending is basically very sound - using a 'multipage' on a single UserForm greatly simplifies data handling - with single declaration of variables at the head of your code makes them available throughout the app.
    Get away from all the Command Buttons on your sheet and also remove all formula and conditional formatting - use your sheet just as a 'pseudo' database and do all your calcs within your code.
    Sample of use of multipage attached just as an illustration of possible content.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  6. #6
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: Combining UserForm Controls

    Hi torachan. Thank you, you have actually helped many times and I have been going through your examples and those in other posts. Unfortunately, I cant seem to understand how to adapt what you've done into my workbook - it never works and I'm not understanding how to.

    My formula in the 'record' column is used to add/amend/track records, this was created by a friend who unfortunately is no longer around and therefore cannot help me with my workbook. I'm not sure how to replace the way he used the formulas to track in and out records.

    The conditional formatting - I have tried and asked for help turning it into code with no solution, I have no idea how to and I need to have it, if it could be in code instead great, but I cannot figure out how to do that.

    I would absolutely love to have multipage but my VBA knowledge has come to its limit and I have no clue how to adapt any of your lovely examples into my user forms.


  7. #7
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Lightbulb Re: Combining UserForm Controls

    Okay, I have made a few changes, added multipage and put a few things on one - Most is working.

    My issue now is the data at the bottom of my userform seems to change based off other controls that i use - How do i make the data stay without any changes even if i 'clear' the userform?

    My code looks messy too - easy way to clean it up?
    Attached Files Attached Files

  8. #8
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Combining UserForm Controls

    Sorry, I would suggest starting from a 'blank canvas' - the convoluted code overloaded my aged one brain cell.
    without deeper investigation I can not understand why pressing your Sub CommandButton4_Click() should launch another copy of your userform.
    Also I cannot figure out how you have managed to place on the form body the boxes that give the data from your 'INFO' sheet.
    The reason I say start again is the fact the code flow is so complicated due to everything being patched together from various persons methodology it has become almost impossible to assist constructively.
    Settle with one approach - this depends on your vision - however do not mix on sheet coded buttons with the use of UserForms - getting them to talk to each other is the making of a nightmare.

  9. #9
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: Combining UserForm Controls

    Hi torachan - Sorry about that.

    I wish I could start again but I just dont have the knowledge to do so - I can create the userform interface, not the coding behind it :/

    I mentioned above, I had a friend who put it together for me, I've amended it here and there but he did most of the code - unfortunately he's passed away and so I cant even ask :/

    Would it be a lot to ask if I create the form and you can assist in the code? - I do feel like that is a bit much to ask but I dont know where else to turn.

+ 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. Userform Login on userform and disabling/enabling userforms controls
    By waimea in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2019, 10:37 AM
  2. Adding controls to Userform from another Userform
    By AdiK in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-09-2017, 11:49 AM
  3. [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
  4. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  5. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  6. 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
  7. UserForm Controls
    By newbie13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2008, 05:37 AM

Tags for this Thread

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