+ Reply to Thread
Results 1 to 10 of 10

Adding up textbox values in multipage - page 1 is fine, page 2 stops

  1. #1
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Hi there,

    in a userform multipage, I need to create multiple textboxes and a label which sums them up in a "live" manner which means that as soon as a value is entered/changed in a textbox, the label value changes. This may happen on mutiple pages but depending on inputs, some multipage pages may not have these functionalities. I read some similar issues in this forum and using class modules, I managed to do that... almost. The problem is: If only one page has textboxes and the label, it works perfectly. As soon as a second page has the same functionality, it stops working. So my first thought went to the textbox naming but all textboxes have unique names and are called by them so I cannot spot the mistake. I hope you can help me with that.

    Creation of textboxes (all within a for loop which goes through the multipage pages using i):
    Please Login or Register  to view this content.
    Creation of sum label:
    Please Login or Register  to view this content.
    Class module stuff (from this forum. I don't fully understand it but it does the job):
    Please Login or Register  to view this content.
    Within the class module:
    Please Login or Register  to view this content.
    AutoCalc:
    Please Login or Register  to view this content.
    I assume this is the essential code. Let me know if you need more. If required, I could try to attach a minimal example workbook but as the actual work is confidential, this would need a quite a bit of rework so I thought maybe this code is already enough to solve the issue.

    Any help is much appreciated!
    Last edited by Menohavename; 03-17-2020 at 01:57 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    This does the job without using a class module:

    Please Login or Register  to view this content.

    This is better:

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-17-2020 at 01:47 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Hi,

    thank you for your reply. Your solution does not add up the scores "live" but only once the button is clicked, right? I need that live function though. I did not describe this detail in my original statement, I'll add it now.

  4. #4
    Registered User
    Join Date
    02-23-2020
    Location
    France
    MS-Off Ver
    2019
    Posts
    44

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Hi,

    Quote Originally Posted by mehmetcik View Post
    This does the job without using a class module:
    If you quit using the class module, you will also loose the Change event processing! Don't do that!

    Please post the integral contents of your Userform code. I don't see the loop that goes through the multipages.
    Better : save your userform and post the resulting file.

    Thanks,
    --
    LR

  5. #5
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Quote Originally Posted by ArdusPetus View Post
    Better : save your userform and post the resulting file.
    Great idea, thanks! Here it comes, together with the class module.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-23-2020
    Location
    France
    MS-Off Ver
    2019
    Posts
    44

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Just before the end of the main loop (For i = 0 to numberOfFactors - 1, you have the folllowing code:
    Please Login or Register  to view this content.
    The first line initializes the collection, erasing its previous contents from previous pages. That is wrong. You should move that code outside of the loop, at the beginning of the Initialize Sub.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Theoretically yes, but the textboxes are generated dynamically and their number can vary between 1 and 100 so this doesn't work, unfortunately.

    Quote Originally Posted by ArdusPetus View Post
    The first line initializes the collection, erasing its previous contents from previous pages. That is wrong. You should move that code outside of the loop, at the beginning of the Initialize Sub.
    That makes sense, yes. Unfortunately, I changed it accordingly but the issue still remains.

    I thought about the confidentiality issue again and I think it should be fine. Therefore, find the file attached. It would be fantastic if you could please have a look at it. The instruction to reproduce the issue is:
    - Add an alternative of your choice
    - Add a decision criterion to factor "Performance"
    - Go to Weighting and you'll see that it works perfectly, both on the first multipage as well as on the performance multipage
    - Close and add another criterion, to "Mass" for instance.
    - Go to Weighting again and it doesn't work anymore.

    What I figured out now is that now the sum is not calculated across all the textboxes on the same multipage but adds up all textboxes on all pages. On multipage Performance, this doesn't happen in a "live" manner while it does on multipage Mass. Now I'm totally confused.

    Edit: Attachement removed because I don't want to have it to be available online anymore.
    Last edited by Menohavename; 03-23-2020 at 06:50 AM.

  9. #9
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Any idea, ArdusPetus or anybody else?

  10. #10
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Adding up textbox values in multipage - page 1 is fine, page 2 stops

    Quote Originally Posted by ArdusPetus View Post
    That is wrong. You should move that code outside of the loop, at the beginning of the Initialize Sub.
    I got it up and running now! I tried this again and somehow I guess I made a mistake the last time. Then there was a slight glitch in the sum function but I got that fixed, too. Thank you so much!

+ 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] Multipage Control - Page Contents not changing with coded page change
    By Jenn68 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-26-2022, 08:20 PM
  2. Replies: 6
    Last Post: 06-05-2018, 04:53 PM
  3. Adding a page to Multipage with code
    By AdiK in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-13-2017, 07:11 AM
  4. Replies: 4
    Last Post: 08-28-2014, 02:23 AM
  5. Autofill TextBox on each page of Multipage Userform
    By kimmcms in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-20-2013, 06:45 PM
  6. Hiding Content of specific Multipage page but not the page tab
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2010, 03:42 AM
  7. Adding controls to each page in a multipage form
    By michael fuller in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2006, 05:50 PM

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