+ Reply to Thread
Results 1 to 5 of 5

Msgbox from Userform - how to return to Userform and retain the inputs

  1. #1
    Registered User
    Join Date
    08-15-2016
    Location
    Leeds, England
    MS-Off Ver
    2013
    Posts
    14

    Msgbox from Userform - how to return to Userform and retain the inputs

    Hello!

    I have made a userform, and some of the fields are mandatory. I have created Msgboxs to appear if any of these are empty, prompting the user to go back and complete them. I have achieved this with:

    Please Login or Register  to view this content.
    where "sizingwizard" is the name of the Userform.

    However, when I use this method, the Userform comes back empty. It's quite a large Userform, so if the user has spent 3 minutes filling it in and they miss a field, I don't want the Userform to get wiped of all their entries after the warning Msgbox goes away.

    I also tried:
    Please Login or Register  to view this content.
    which omits the "Unload Me" part, but this gives me an error: "Form already displayed; can't show modally."

    What can I do? Am I missing something obvious?? Thanks!

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

    Re: Msgbox from Userform - how to return to Userform and retain the inputs

    Set focus to the control...

    Please Login or Register  to view this content.
    Unloading the userform clears any input controls.

  3. #3
    Registered User
    Join Date
    08-15-2016
    Location
    Leeds, England
    MS-Off Ver
    2013
    Posts
    14

    Re: Msgbox from Userform - how to return to Userform and retain the inputs

    Thanks cytop, that's working better. The information in the userform is still there once the Msgbox has been dismissed. However, when I click "OK" on the Msgbox, the macro continues to run its course.

    This particular macro runs when the user clicks a command button at the end of the form. Once the user clicks the command button, if one of the fields is empty, the warning pops up. When they click OK, the form reappears with the information still completed, but what's happening is that the command button macro still runs, ignoring the empty field. I want it to stop and wait for the user to click the command button again. Any thoughts?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Msgbox from Userform - how to return to Userform and retain the inputs

    Why are you unloading the userform?

    You should still be able to display the message box without doing that.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    08-15-2016
    Location
    Leeds, England
    MS-Off Ver
    2013
    Posts
    14

    Re: Msgbox from Userform - how to return to Userform and retain the inputs

    Hi Norie, it's because I'm running into the same problem as I described in my reply to cytop above - once the user dismisses the Msgbox, the macro continues to run rather than stopping to let the user enter the correct information.

    I have fixed it - a swift Exit Sub does the job! The Userform stays visible after the Msgbox is dismissed, complete with the info that was there before, and the user has to click the command button to run it again:

    Please Login or Register  to view this content.
    Thanks both for helping me think it through

+ 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. Exit Userform to return to main code, but keep userform open
    By jombler74 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-04-2014, 04:01 AM
  2. Return to userform after msgbox?
    By dbjofo in forum Excel General
    Replies: 11
    Last Post: 02-06-2014, 12:58 PM
  3. Return to userform after msgbox??
    By dbjofo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2014, 11:47 AM
  4. Retain data in checkbox in Userform
    By Speurneus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2013, 06:28 AM
  5. UserForm - How to retain wrksht data in userform and reverse
    By JasonRay in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-08-2013, 05:32 PM
  6. [SOLVED] Userform msgbox option to return to parent form
    By Hammer_757 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2012, 02:19 PM
  7. Userform ComboBox - Retain Value
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-19-2010, 11:10 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