+ Reply to Thread
Results 1 to 13 of 13

hide vs unload

Hybrid View

  1. #1
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    hide vs unload

    I use several different userForms at different times in my macro. I am having an issue where soemtimes Excel will be stuck (not frozen) after I close a form. Its almost like the form is being hidden but Excel thinks that it is still visible, so execution halts.

    I've tried leaving the form with both me.hide and unload me. My code is pretty lengthy, so I don't think submitting it is appropriate. I believe my problem is my own lack of knowledge on hide vs unload.

    Can anyone help me out here?
    Last edited by gtmeloney; 07-29-2009 at 06:37 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: hide vs unload

    Unload removes it from memory, so that all value will return to those created at design time when next shown.

    Hide just removes it from display, preserving values.

    I don't think that's the source of your problem.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Re: hide vs unload

    Thanks shg.

    Any idea what would cause my problem?

    Here's my scenario. I have formA and formB. formA is displayed using formA.show (from another module). formB is then displayed using formB.show from within formA. Sometimes everything works fine after closing formB (using either hide or unload), but other times I get Excel stuck (have to kill the process to do anything else). Surprisingly though, the debugger is still running.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: hide vs unload

    Dunno, gt, I really don't spend a lot of time with forms. Perhaps formB is parented by formA, and becomes orphaned if formA is sometimes closed first? I do have an app that includes a subform invokes by a main form, but have never had a problem, and therfore no problem to figure out.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: hide vs unload

    The best way to avoid these problms is one form with a MultiPage control
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: hide vs unload

    How do you get from FormA to FormB and back? It's quite common to see people using FormB.Show in FormA, then in FormB using Unload Me (or Me.Hide) in conjunction with FormA.Show but that can leave you in a big loop since processing switches to the other form without actually completing in the form you are trying to unload. Once you have done that a few times, it's one big spiral...
    Everyone who confuses correlation and causation ends up dead.

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

    Re: hide vs unload

    Hello gtmeloney,

    I have encountered this problem when one form is modal and the other is not. The default is to display the UserForm modally. The ShowModal property ensures one and only one UserForm can accept user input. This prevents other UserForms or the application from accepting user input.

    When showing UserForms as non-modal, I modify them using the API to function like a standard window. This allows the UserForm to retain its information and interact with the application. You may want to use this approach for what you 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!)

  8. #8
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Re: hide vs unload

    Thanks for all the help folks. I haven't found a fix for my issue, but I'm still trying. I think part of my problem might be that I have refEdit controls on the form in question. I'm not sure if the modality of the userForm and the modality of the refEdit controls are conflicting.

    Is there anything that I need to do when using refEdit controls, in order to avoid problems like this?

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: hide vs unload

    Avoid putting them on Multipage or Frame controls generally. (Some would say avoid them altogether and use Application.Inputbox with Type:=8 instead)

  10. #10
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Re: hide vs unload

    Thanks romper. I'm going to give that a whirl to see if it eliminates my problem. I'll follow up whether or not it works.

+ 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