+ Reply to Thread
Results 1 to 3 of 3

Closing userform with X multiple times ??

  1. #1
    Registered User
    Join Date
    04-02-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    38

    Closing userform with X multiple times ??

    Consider the following, given two UserForms: UserForm1 and UserForm2.

    Command button on UserForm1 hides UserForm1 and shows UserForm2
    Private Sub UserForm_QueryClose on Userform2 hides UserForm2, then Unloads UserForm2 and then shows UserForm1

    When Userform1 is showing and I click on the command button, UserForm2 shows. When I close out UserForm2, Userform1 shows as expected. If I click on the command button a second time, UserForm1 hides and UserForm2 shows. If I then try closing Userform2 again, nothing happens when click the [X]. Why is this?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: Closing userform with X multiple times ??

    Can you post the code you have in UserForm_QueryClose? Even better, post the file.

    Are the forms modal? I tried to reproduce this. When QueryClose tries to open the other form, I get an error because it is attempting to show another form while it is still displayed itself. Both forms are modal so this is not allowed.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Closing userform with X multiple times ??

    userform2 should not show userform1-userform1 should do that itself. so userform1 code is
    Please Login or Register  to view this content.
    and userform2 doesn't actually need any code in its queryclose event since it's being unloaded anyway
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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