+ Reply to Thread
Results 1 to 11 of 11

Yes/no msgbox -> if no is clicked, show userform with data still in it

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Yes/no msgbox -> if no is clicked, show userform with data still in it

    Hi,

    Been breaking my head over this one:
    Got a sub that checks if 1 value is different from another value when you want to save the userform and write data to worksheets. If they are different, a msgbox is shown. When the user clicks yes, the sub writes another value and you can proceed. If the user clicks no, he should just go back to the useform, but with all data still visible (so don't clear the whole thing).

    this is my code:

    Please Login or Register  to view this content.
    If I only use
    Please Login or Register  to view this content.
    , i get a message it's already open.
    The problem with the code I'm currently using, is that when a user tries to save the userform multiple times, and clicks 'No' multiple times, the userform opens 'X' amount of times (4x clicked 'No' - 4 userforms show behind eachother. So when i press cancel on the userform, I need to cancel 'X' times.

    Anyone know a decent way of just 'unloading the messagebox and return to the filled in userform?


    Thank you!
    Last edited by pclaesen; 02-04-2016 at 11:53 AM.

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Have you tried Else Nothing? I mean:
    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    That doesn't work, the userform still continues (aka is saved).

  4. #4
    Valued Forum Contributor Gatti's Avatar
    Join Date
    06-08-2015
    Location
    Brasil, São Paulo, Ribeirão Preto
    MS-Off Ver
    365
    Posts
    346

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Use Unload Aankoopfactuuringave, instead of .Hide

    Hide means you literally hide your form, but didn't close it

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

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Try..
    Please Login or Register  to view this content.
    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

  6. #6
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Quote Originally Posted by Gatti View Post
    Use Unload Aankoopfactuuringave, instead of .Hide

    Hide means you literally hide your form, but didn't close it
    Unload erases all that date the user has submitted in the form. I'm looking for a solution where the msgbox just gets closed, and the user goes back to the userform he just tried to save.



    Thanks for the replies tho, appreciate your time !

  7. #7
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    ave you tried
    Please Login or Register  to view this content.
    ???
    Can you upload a sample?

  8. #8
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Quote Originally Posted by gmr4evr1 View Post
    Try..
    Please Login or Register  to view this content.
    I get an error on the 'yes', not defined. When I define it, I get other errors.

    Quote Originally Posted by bulina2k View Post
    ave you tried
    Please Login or Register  to view this content.
    ???
    Can you upload a sample?
    I created a sub for this routine, but the exit sub also clears the entire userform.

    Maybe I should work with an OK and Cancel msgbox, maybe the cancel will just show me back my userform?

  9. #9
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Quote Originally Posted by bulina2k View Post
    ave you tried
    Please Login or Register  to view this content.
    ???
    Can you upload a sample?
    Ok this worked (disregard my previous post). I made a new Sub, but of course this caused the new sub to exit when the user clicks No.
    With this piece of code, my sub 'save' new exits and just shows me the userform with the data.

  10. #10
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    Thank you for the rep pclaesen. Glad I could help.

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

    Re: Yes/no msgbox -> if no is clicked, show userform with data still in it

    pclaesen,
    Sorry about that, I made a mistake on that line. I know you already have the issue resolved, but I'll provide you with the corrected code for reference..
    Please Login or Register  to view this content.

+ 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] VBA code to show updated data in the listbox after the data is entered and button clicked
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2015, 04:23 AM
  2. Populate data when monthview clicked on userform
    By imzhakmaya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2014, 05:38 AM
  3. [SOLVED] Userform Cancel button when clicked still inputs data
    By Mr_Bill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2014, 01:04 PM
  4. Aborting code after a MsgBox has been clicked
    By Luke8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2014, 07:03 PM
  5. [SOLVED] Suppress msgbox and userform.show
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2014, 05:38 AM
  6. Need to run macros depending on msgbox button clicked
    By rosshkerr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-01-2012, 06:07 AM
  7. msgbox apear if macro clicked
    By shilpz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-17-2008, 06:49 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