Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long Delays in Unloading Userform

Status
Not open for further replies.

senators40

Technical User
Jan 7, 2003
68
CA
Hi,

I have a userform (Form1) and I have another userform on top if a certain event happens. (Form4)

On the second userform (Form4) I have a command button that says Completely Start Over.

In that code for the Completely Start Over button I state the following

Unload Me
Unload Form1
Unload Form2
Unload Form3

When it starts to unload Form1 Excel hangs. When I run through on the step it seems to hang on the Unload Form1 for about 20 seconds before it proceeds (even longer on older computers)

I tried recreating it using simple macros and it doesnt have a problem with it.

The interesting thing is that when I do it manually - ie close the original form and then click on the Cancel button (which has all the Unload Form1, Unload Form2 Unload Form3) there is no delay.

I tried to delay the pressing of the command button (just in case there was a screen refreshing issue or something) but it didn't help as well.

The form in question has over 450 items on it (labels, textboxes, commandboxes etc and the code has 20,000 lines)

I am using Excel 2002 (10.6829.6830) SP3 on Windows xp. I also tried running it with Excel 2000 and Windows 98 and experienced the same problem.

Any help would be appreciated.

Thanks,

Jeff







 
Try:
Code:
Unload Form1
Unload Form2
Unload Form3
[blue]Unload Me[/blue]
Move Unload Me as the last statement

If you Unload the Form that you are on, and then you have another line to execute, even Unload Form1, Form1 has to be loaded to be unloaded.



Have fun.

---- Andy
 
Hi,

I tried that but it still hangs.

I also show the same situation during the following event

Form1 loads. I hide Form1 and Show Form2. On top of Form2 I show Form3.

I give the user the option to go to Form2 or go back to Form1. If they go back to Form1 I have a button on Form2 to go back to Form1.

Once this happens the delay occurs again, when I do unload Forms1, 2, and 3. If in Form2 I click goto Form2 there is no delay when cancelling.

Thanks,

Jeff
 
Jeff,

Per your comment below:

The interesting thing is that when I do it manually - ie close the original form and then click on the Cancel button (which has all the Unload Form1, Unload Form2 Unload Form3) there is no delay.

Is the Cancel button on Form1? Also when you manually close Form4 (thus going back to Form1) does it hang in the transition?

Lastly, which form is loaded first? Naturally I'm going to assume Form1, thus Form2, then Form3?

It would make more sense to me if you unloaded forms in the order they are stacked: 4, 3, 2, 1.

BD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top