+ Reply to Thread
Results 1 to 11 of 11

Multi-Page Userform error switching pages

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Multi-Page Userform error switching pages

    Hi folks,

    I'm deploying a Multi-page Userform through which my users will add a client entry to a database.
    But I'm receiving the following error message which I attempt to click my 'Next button'.error.png

    The debug in VBA highlights the following code which is handling the multi page. Can anyone suggest where I've gone wrong here?

    Private Sub NextButton_Click()
    MultiPage2.Value = MultiPage2.Value + 1
    UpdateControls
    End Sub

    One issue seems to be that the userform isn't always starting from page 1, but often from page 4. Is thre anything to be done about this?

    Many thanks all,

    Henry

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Multi-Page Userform error switching pages

    Are these "stand alone" UserForms, or forms on a spreadsheet? If stand alone, you can use Unload Userform1 Userform2.Show. Change the Userform names to what yours are to get them to work properly.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multi-Page Userform error switching pages

    The Value of a Multipage is 0 based. i.e. if Value = 0 then page 1 is showing.

    To loop through the pages without error you could use this. The Mod keeps the value within the required range

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: Multi-Page Userform error switching pages

    Thanks both for the speedy replies:

    Tom: Not sure I get the distinction? My Userform is standalone i think but I'm summoning it into a specific worksheet via an event handler, if that helps?

    Mike: I've replaced my code for the next button and the code for the 'previous' button with yours, except for the previous one for which I changed the sign to be a minus. It works! The only, rather minor point is that once we reach the last or first pages the buttons don't get greyed out as they used to, but instead come full circle so that you will move from page 10 back to page 1 once you've finished.
    Is there any way to get it to recognise where the 'end' point is? This is not essential, though.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multi-Page Userform error switching pages

    To Grey out

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: Multi-Page Userform error switching pages

    Quote Originally Posted by mikerickson View Post
    To Grey out

    Please Login or Register  to view this content.
    Ok, thanks, just a couple of questions:

    1) Why is there a dot/period in between Multi and Page? My Multipage is called Multipage2 - I took away the period sign but it hasn't worked so far.
    2) Forgive my noobishness - both codes seem to contain Value +1 and Value - 1 and also CommandButton 1 and Command Button 2. Why is this?


    UPDATE,

    Have used the following with some success:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    I don't get any error messages BUT the next button greys out on the penultimate page rather than the last. If I then scroll to the very beginning, I'm finding both buttons greyed out and there's no way to move.

    I'm sure I must have done something wrong, probably regarding the Command Button1 and Command Button 2 which I chaged to fit my private sub name.

    Thanks again for your help.
    Last edited by henryBukowski; 01-06-2016 at 11:32 AM.

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Multi-Page Userform error switching pages

    Henry
    Tom: Not sure I get the distinction?
    I think using the term "stand alone" was not the correct way to describe what I was trying to convey. I think "pop-up" Userform might have been better. Meaning does your Userform open in it's own "pop-up" window, or is it in/on a worksheet?

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multi-Page Userform error switching pages

    1) The dot is a typo
    2) I was hypothesizing a situation where CommandButton1 was Next and CommandButton2 was Previous. Each of them has to deal with the Enabled of both buttons. And I came up with a universal test for each that both routines used.

    In both your two routines, you should change this line.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: Multi-Page Userform error switching pages

    Quote Originally Posted by mikerickson View Post
    1) The dot is a typo
    2) I was hypothesizing a situation where CommandButton1 was Next and CommandButton2 was Previous. Each of them has to deal with the Enabled of both buttons. And I came up with a universal test for each that both routines used.

    In both your two routines, you should change this line.
    Please Login or Register  to view this content.
    Better!!!
    The only thing now is reenabling the buttons once there is room for this to happen. They remain greyed out at present.

    Cheers,
    H

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multi-Page Userform error switching pages

    The greying out might be better driven by the MultiPage1_Change event rather than the Command Button code.

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multi-Page Userform error switching pages

    This is a straightforward solution that I've come up with. The reason for the Intialize event is to make sure that the Enabled properties are set right from the start.
    Please Login or Register  to view this content.
    The MOD function is only needed if one wants Next (or Back) to loop. Since your style is to disable inapplicable buttons, Mod is not needed.

+ 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] Print all pages in a Multi page userform
    By Alro in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-24-2020, 03:54 PM
  2. Unable to hide different pages using the multi-page element
    By gunsmith01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2014, 10:26 PM
  3. Replies: 7
    Last Post: 07-23-2014, 06:15 AM
  4. [SOLVED] Switching Userform Error
    By amotto11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2013, 05:18 PM
  5. [SOLVED] Excel VBA - Dynamically Adding a Page to a Multi-Page UserForm
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 116
    Last Post: 12-13-2012, 05:26 PM
  6. [SOLVED] Combobox in page 2 of multi page userform excel 2003
    By AliiShariff in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2012, 07:37 PM
  7. [SOLVED] I want to print multi pages on one page.
    By Laurie in forum Excel General
    Replies: 2
    Last Post: 08-24-2005, 07:05 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