Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
what is the best method of closing a userform,, i know you can use the
unload userform, but wheres the best place to put this. i have a form with a few commands buttons on it. from the command buttons i only use the call function i.e call nextsub then the first line of code within this sub would be unload userform1. also i would open another form at the end of this sub using the userform2.show. Is this enough to ensure userform1 is closed john |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
The normal practice is to have an OK and a Cancel button on a form. Cancel
unloads without hesitation, OK might do some saving of data. If you want to call another form (say Form2) from your button (in say Form1), showing Form2 in itself does not unload Form1, you have to explicitly do it. But you need to unload Form1 before you show Form2, else it will wait for Form2 to unload in its turn before Form1 unloads. Unload Me UserForm2.Show -- HTH RP (remove nothere from the email address if mailing direct) wrote in message oups.com... what is the best method of closing a userform,, i know you can use the unload userform, but wheres the best place to put this. i have a form with a few commands buttons on it. from the command buttons i only use the call function i.e call nextsub then the first line of code within this sub would be unload userform1. also i would open another form at the end of this sub using the userform2.show. Is this enough to ensure userform1 is closed john |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
Simply showing userform2 will not close userform1. It will cause
userform2 to be displayed above (on top of) userform1. To close userform1, use the Hide method if you want to keep userform1 in memory (so you can still read values from its controls), or the Unload statement if you want to dump userform1 from memory. Either of these statements should be before the Show method of userform2. wrote in message oups.com... what is the best method of closing a userform,, i know you can use the unload userform, but wheres the best place to put this. i have a form with a few commands buttons on it. from the command buttons i only use the call function i.e call nextsub then the first line of code within this sub would be unload userform1. also i would open another form at the end of this sub using the userform2.show. Is this enough to ensure userform1 is closed john |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
thanks so would having a button on userform 1 that calls a module that
first unloads form1 then opens form2 would be ok ie. Private Sub CommandButton6_Click() Call finnish End Sub sub finnish () unload userfrom1 various lines of code userfrom2.show end sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
in essence yes, but get the order right
sub finnish () various lines of code unload userfrom1 userfrom2.show end sub -- HTH Bob Phillips wrote in message oups.com... thanks so would having a button on userform 1 that calls a module that first unloads form1 then opens form2 would be ok ie. Private Sub CommandButton6_Click() Call finnish End Sub sub finnish () unload userfrom1 various lines of code userfrom2.show end sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
closing userforms
The order in the original looked fine to me. What is the advantage or
rightness of doing various lines of code prior to unloading userform1? -- Regards, Tom Ogilvy "Bob Phillips" wrote in message ... in essence yes, but get the order right sub finnish () various lines of code unload userfrom1 userfrom2.show end sub -- HTH Bob Phillips wrote in message oups.com... thanks so would having a button on userform 1 that calls a module that first unloads form1 then opens form2 would be ok ie. Private Sub CommandButton6_Click() Call finnish End Sub sub finnish () unload userfrom1 various lines of code userfrom2.show end sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Closing workbooks w/o closing Excel | Excel Discussion (Misc queries) | |||
userforms | Excel Programming | |||
Closing VB triggers closing Excel | Excel Programming | |||
Userforms | Excel Programming | |||
closing excel after closing a workbook | Excel Programming |