PDA

View Full Version : Unloading User Forms



Hockenmaier
06-24-2010, 03:09 PM
Quick questions guys:

I know that the "Unload Me" function works to unload the current form, but how do you unload a different form that may, for example, be hidden? I've tried simply saying "Unoad OtherForm" (where OtherForm is the name of the other form) but I get an error telling me I can't do that.

Does anyone know how to do this? Do I have to bring the up real fast and unload them?

Thanks

Bob Phillips
06-24-2010, 03:40 PM
What error do you get, something about a modal form?

Tinbendr
06-24-2010, 06:39 PM
They have to be treated as nested objects. (or z-order)

Else you get


Must close or hide topmost modal form first (Error 402)

The modal form you are trying to close or hide isn't on top of the z-order (http://javascript%3cb%3e%3c/b%3E:hhobj_2.Click%28%29). This error has the following cause and solution:
Another modal form is higher in the z-order than the modal form you tried to close or hide. First use either the Unload statement or the Hide method on any modal form higher in the z-order. A modal form is a form displayed by the Show method, with the style argument set to 1 – vbModal.You will have to Load Userform2, pass any data to it from userform1, Unload the Userform1, then Userform2.Show.

Bob Phillips
06-25-2010, 02:04 AM
Not if you load them modeless, then they can be independent.

Simon Lloyd
06-25-2010, 02:24 AM
I was going to chip in Bob that the forms should be modeless but then thought better of it as focus can be set to the worksheet or wherever else with a mouse click, just from my own experience it can leave data open to be manipulated that may have already been accounted for in the userform_initialize, then you do get odd results :)

Bob Phillips
06-25-2010, 02:41 AM
There are many ways to control many situations Simon. Bottom line is that it depends upon the OPs requirement, and they haven't given that, just the problem they encountered.