Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Userform unloaded not hidden (2003)

    OK, this is driving me crazy. I want a userform to look the same as when the user last saw it - i.e., to "remember" the selections made. I just mean during the current session, so you'd think "Me.Hide" would do the trick (as it has previously). However, in this particular workbook the userform is only hidden until control is returned back to the user. At that point the userform is unloaded thereby losing the settings - and I can't figure out why.
    Has anybody run into the same thing or have suggestions as to why it might be happening?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Userform unloaded not hidden (2003)

    Do you have code that unloads the form? For example, if you have put a command button on the userform with code like

    Unload Me

    in its On Click event procedure. Otherwise, the userform should retain its settings during a session.

    If you can't find the cause, you could perhaps post a stripped down copy of the workbook (zipped if necessary), with all sensitive content removed.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Userform unloaded not hidden (2003)

    Thanks (again), Hans. It turns out to be our old friend "lstOverlay" - that misbehaving list box that you were helping me with the other day.
    Check out the attached example and I think you'll see what I mean.

    It seems like it must be an Excel bug in that if a list box has been added to a sheet, then when control is returned to the user, all hidden userforms are unloaded. But I'd be interested in your thoughts...

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Userform unloaded not hidden (2003)

    I don't know if you can call this a bug. Adding or removing a list box probably counts as a change in the VBA project (even if the list box is on a worksheet), so it resets all VBA items and objects. A possible workaround would be to store the settings in a worksheet in the cmdClose_Click event procedure and to reload them in the UserForm_Initialize event procedure.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Userform unloaded not hidden (2003)

    Gotcha. That would also explain why I was unable to set break points - which was something else that was puzzling me.
    Many thanks,
    Colin.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •