+ Reply to Thread
Results 1 to 14 of 14

How do you unload only the top UserForm?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    How do you unload only the top UserForm?

    Hi,

    When I have two UserForms open at the same time and I click on the "X" close button in the upper right hand corner of the top most form, ALL the forms unload. Is there code that changes that X button to only unload the form in which it resides and keep the other form loaded/shown?

    Thanks,

    Lawrence
    Last edited by skysurfer; 04-08-2010 at 10:58 PM.

  2. #2
    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: How do you unload only the top UserForm?

    Hello skysurfer,

    You should post your workbook. I have tried to reproduce this problem without success.
    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!)

  3. #3
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How do you unload only the top UserForm?

    Quote Originally Posted by Leith Ross View Post
    Hello skysurfer,

    You should post your workbook. I have tried to reproduce this problem without success.
    Hi Leith,

    Just got back and was preparing the workbook to be posted for you when I tested the issue...and there was no issue. That is, after shutting down Excel and then reloading the program and the workbook there is now no problem.

    However, I still would like to gain greater control over that X close button. Is it possible to apply code to it that will make the form hide instead of unload?

    Thanks!

    Lawrence

  4. #4
    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: How do you unload only the top UserForm?

    Hello skysurfer,

    The UserForm can tell if the close box was clicked or not.
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
      If CloseMode Then Me.Hide
    End Sub

  5. #5
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How do you unload only the top UserForm?

    Thanks Leith.

    Where do I put that code? I tried it in the Forms and clicking on the X still unloads the UserForm. I'm trying to hide the form so when it is triggered to show again the last page on the MultiPage will be the 1st page seen.

    Lawrence

  6. #6
    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: How do you unload only the top UserForm?

    Hello skysurfer,
    1. Open the Visual Basic Editor and select a UserForm
    2. Press F7. This inserts the default event Private Sub UserForm_Click() into the UserForm.
    3. Above this window are 2 drop down lists. The one on the left is for Objects and the one on the right is for events.
    4. Click the righthand drop down list. Scroll down the list to QueryClose
    5. Insert the following line of code If CloseMode Then Me.Hide
    6. Repeat these procedures for each UserForm you want to hide instead of close.

+ 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