+ Reply to Thread
Results 1 to 10 of 10

Userform cancel button to stop background proces

  1. #1
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Userform cancel button to stop background proces

    Hello,

    I created a userform that will pop-up in the middle of a pocess once a duplicated record is found on the sheet. This userform will prompt the user to either cancel or continue with the duplicated record. To continue is easy, i simply unload the form; however stopping the process is proving to be a bit more difficult. If i unload the form the process continues, how can i code the cancel button i created on the form that once pressed it stops all the macros that was running on the sheet?

    The usform is simple, it has two buttons, one to continue, one to cancel (that should stop the already running process).

    Kindly assist if possible thank you.

  2. #2
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Userform cancel button to stop background proces

    Help anyone, this issue is really preventing me from continuing with my code.

    Help please

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Userform cancel button to stop background proces

    Hello kmakjop,

    Post your workbook so we can see what your code and what your are doing.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Userform cancel button to stop background proces

    Quote Originally Posted by Leith Ross View Post
    Hello kmakjop,

    Post your workbook so we can see what your code and what your are doing.
    Thanks for responding. However its not that complicated. The application is creating a text file and if detects a duplicate record in the sheet it will show the userform. the userform will prompt the user to either continue or cancel. If he clicks cancel i unload the form and the process continues. If he clicks cancel, then the entire application should halt and stop there-do nothing else until process is initaited again. I was thinking that there was a code that i could place under the cancel button's click event that will just end all process, but either no such code or i just cant find it over the internet.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Userform cancel button to stop background proces

    Hello kmakjop,

    Don't unload the user form, but Hide it. This will keep your variables and their values intact. You can have your Cancel button set a boolean variable that your other code can check. If the variable is true then stop the process by exit then code and unloading the user form.

  6. #6
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Userform cancel button to stop background proces

    Quote Originally Posted by Leith Ross View Post
    Hello kmakjop,

    Don't unload the user form, but Hide it. This will keep your variables and their values intact. You can have your Cancel button set a boolean variable that your other code can check. If the variable is true then stop the process by exit then code and unloading the user form.
    Okay thanks. Give me a few minutes to try and execute what you said, i will post my results shortly...Thank you again.

  7. #7
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Userform cancel button to stop background proces

    Quote Originally Posted by kmakjop View Post
    Okay thanks. Give me a few minutes to try and execute what you said, i will post my results shortly...Thank you again.
    Ok i did something similar to what you suggested, Just that i had some problems accessing the variables from the userform not sure why. however i just substituted the variable with a specific cell and its fine. I would prefer using an actual variable but it was eating away too much of my time to get it done. But hey variable or cell they both do the samething so its fine for now. Thanks.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Userform cancel button to stop background proces

    Hello kmakjop,

    Good to hear you it working.Should I mark this posted solved?

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Userform cancel button to stop background proces

    Hello kmakjop,

    Good to hear you have it working. Should I mark this posted solved?

  10. #10
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Userform cancel button to stop background proces

    Quote Originally Posted by Leith Ross View Post
    Hello kmakjop,

    Good to hear you have it working. Should I mark this posted solved?
    I am currently searching to see where to add the close tatus to the post, but not seeing that. Yeah go riht ahead, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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