PDA

View Full Version : Solved: Userform do not load properly



ndendrinos
10-16-2010, 10:31 PM
I keep looking at the codes in the userforms and I cant's find what the problem is. ( I suspect that it has to do with the loading / hiding / unloading of same)
From sheet "invoice" search USA first (State and City) then using the command button (or clicking A2) change to Canada... somehow what I get is the states in the USA and not the Provinces in Canada.
Sometimes this problem materializes immediately and sometimes after I run the code several times.
Thank you.

Simon Lloyd
10-17-2010, 02:49 AM
I've not looked at your workbook but if you ae hiding the userforms then why not try unloading them instead like this:UnLoad Userform1

ndendrinos
10-17-2010, 05:03 AM
Hello Simon.
Tried that before posting ... it does not work.
I could post all codes in the wb but I still feel that to help one would have to actually use the file as the problem may have to do with something else.

To mention another anomaly:
If I run the code AND close the file AND save ... then things improve BUT still not perfect.... If I incorporate a "save" in the code without closing the file ,,, that does not work,,, just slows down things.

Strange!
Thank you

Simon Lloyd
10-17-2010, 06:03 AM
Then i guess you should remove sensitive data ( or change it as it should have the same structure) and post the workbook.

ndendrinos
10-17-2010, 07:24 AM
There is no sensitive data Simon but here is a fresh edition done from scratch with the lone module and three userforms imported from the previous example.
Tested and still same problems
Many thanks

Tinbendr
10-17-2010, 10:06 AM
I applaud your effort in cascading userforms.

Sorry, I don't have a answer to your question specifically. but how about cascading drop downs instead.

Check out this version.

ndendrinos
10-17-2010, 11:10 AM
http://www.mrexcel.com/forum/showthread.php?t=32
Cascading drop downs that's what got me started ...

You don't wont to miss the above 105 Posts ... 84,516 views (guess longest on record)

Thanks david I'll have a look at your attachment ...
Just had a look BTW ... same problem with your effort

Tinbendr
10-17-2010, 12:31 PM
Oops, forgot to clear the list.

Try this version.

CharlesH
10-17-2010, 12:36 PM
Hi,


In the attached I added the Unload userform per Simon suggestion. I also added code to select range("A1") in the code for the exit button and in the Ok button. The reason is I noticed that after you made the userform selections the active cell was set to "A2" and you had to click off "A2" then back to it to reactivate the code to show the userform.

ndendrinos
10-17-2010, 03:33 PM
Sorry gentlemen but both last files fail.
Thank you both

CharlesH
10-17-2010, 03:46 PM
Hum,

I just followed your example and I did not have a problem.
The only problem I had was when I tried to select " Quebec" for the State/Providence. It erred to this line of code
Set Rng = Sheets("City").Columns(2).Find(Val).CurrentRegion.Columns(2)
With Object variable not set.

Tinbendr
10-17-2010, 03:55 PM
The only problem I had was when I tried to select " Quebec" for the State/Providence. It erred to this line of code
Set Rng = Sheets("City").Columns(2).Find(Val).CurrentRegion.Columns(2)
With Object variable not set.
I discovered that there are no other cities for Providences in his example other than Ontario. Probably need to test for that.

So, ndendrinos, give us a pattern that fails, along with selections made.

David

CharlesH
10-17-2010, 03:57 PM
Hi,

I too noticed that and probably should have mentioned it in my post.

ndendrinos
10-17-2010, 04:25 PM
Thanks for sticking by .
Here is another file (more populated)
Click the command button
Choose Ontario/Quebec/Montreal
Click the command button again
Choose USA .... form5 will show the Canadian Provinces instead of the American States.
Close the userform5
Click the command button ...
Choose any Country ... the code will work.
If you unload the userforms instead of hiding them you will encounter problems.

Tinbendr
10-18-2010, 11:53 AM
This was the only way I could make it work.

The problem is that the userforms keep calling each other recusively and it is quicky falling into the category of 'not worth the trouble'.

David

ndendrinos
10-18-2010, 04:33 PM
Good work and thanks for the help David
Regards, Nick