MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 7th, 2002, 03:51 PM   #1
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

I have a user form that is open, I click a button on the user form and another user form pops up into view. I press a cancel button on the second user for to close it. But the user form does not close, it simply hides behind the first form. I've tried "hide" and "unload" to close the user form but neither seems to work.

Any suggestions?

TIA DaK
DaK is offline   Reply With Quote
Old May 7th, 2002, 04:13 PM   #2
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

A couple of questions:

1. What version of Excel are you using?
2. Are you using modeless userforms?
3. Are you hiding/unloading the first userform when you show the second userform?
4. Are you using Application.ScreenUpdating = False?
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 8th, 2002, 09:35 AM   #3
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

1. Excel 2000 Small Business

2. Its whatever the default is, I can never remember if that is modal or modeless.

3. Well, I actually did not describe it correctly in my origional post. So here it is. From the first form, there is a button that opens another form. I do not unload/hide the first so it is still visible. From the second form, the user makes a choice which then loads a third form. The second form is then unloaded and the first form is still visible. Now, when the user is done with the third form, they press a "done / cancel" button and then the form is unloaded/hidden. This is the form I am having trouble with, it just hides behind the first form instead of being unloaded.

4. Yes

Thanks for replying...
DaK
DaK is offline   Reply With Quote
Old May 9th, 2002, 07:27 AM   #4
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

It appears that no forms are hiding. I went back and made it so that the first for would hide when the second one was show but the first form just stays there. I tried both modal and modeless. And after I close the second form and drag the first one around the screen, it leaves a trail of its self on the screen until I close the form.

What is going on???

DaK
DaK is offline   Reply With Quote
Old May 9th, 2002, 08:40 AM   #5
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Ok, the dragging over the screen thing. This is one of my favourite things. You can't (actually "shouldn't" is better)use application.screenupdating = false when you show a userform. That's why you're painting the form all over the place. Get rid of this and see if the other forms hide when you want them to. (which it wont, BTW, but it's worth the exercise)

The reason it wont work is because say for example you have userform1 and userform2, on userform1 you have a commandbutton with this code:


Private Sub CommandButton1_Click()
UserForm2.Show
Me.Hide
End Sub


When UserForm2 is shown, this code is still on the line "UserForm2.Show" until it is hidden or unloaded. So the "Me.Hide" to hide UserForm1 doesn't get executed until UserForm2 is removed. (this is probably what you're getting)

Anyway, the simple fix is to hide the form first, then show the other form, which can be done in two ways:


Me.Hide
UserForm2.Show


This just hides the form, it still exists and takes up memory. This other (preferred) method unloads the form and removes it from memory:


Unload Me
UserForm2.Show


Both of these examples, to me, are counter intuitive, but there you go.

HTH
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 10th, 2002, 02:15 PM   #6
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

Thanks for the help, I appreciate it.

DaK
DaK is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:23 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes