+ Reply to Thread
Results 1 to 7 of 7

Different behavior if I close userform via button or x

  1. #1
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Different behavior if I close userform via button or x

    This is the code I use to hide a userform whether it is done by hitting the "Close" button or the "X" at the top right. For some reason when I use the close button then re-open the form it will still show all the typed data that was on the form before closing if I had not submitted it. This does not happen when I hit the X however, when I re-open the form it is once again blank. Anyone know why or where the fault is in my code?

    Please Login or Register  to view this content.
    Last edited by nohero; 07-05-2011 at 04:05 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Different behavior if I close userform via button or x

    Hi nohero,

    I'm not a programming wiz, but the code linked to your command button is simply hiding the form, not closing it and releasing it from memory.

    When you close a form via the 'x', even though you added code to hide the form, the form will actually be closed and the memory released.

  3. #3
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Different behavior if I close userform via button or x

    Does anyone know of a way to make the little red X not actually close the form and just hide it? The reason I want to hide instead of unload is because of a bug that I have not found a resolution for described here:

    http://www.eggheadcafe.com/software/...-error-75.aspx

    It only affects one of the 6 systems in my office but it is still a nuisance for that one user. The workbook works fine for everyone else but will cause run time error 75 when a userform is unloaded then the user tries to load it again after a few minutes.

    The OP from the link I posted determined that hiding the forms is a somewhat usable workaround for the issue and from testing it I found that it does work. Now I just have to tie it in to the X as well as the close button.

    Ideas on how to do this?

  4. #4
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Different behavior if I close userform via button or x

    Before someone suggests I have that one user NOT hit the red X I just want to add that other users will be working from this machine in the future as well as multiple other systems at our other office for which I still have not determined how many systems will have the same bug.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Different behavior if I close userform via button or x

    In the QueryClose code, insert
    Please Login or Register  to view this content.
    Notice one of the parameters in the QueryClose function is "Cancel as Integer". When Cancel = 1 (TRUE) the Close does not occur. When it's 0 (FALSE), the close occurs.

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

    Re: Different behavior if I close userform via button or x

    You need:
    Please Login or Register  to view this content.
    to stop the form from being unloaded.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Different behavior if I close userform via button or x

    Thanks guys!

+ 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