Consulting

Results 1 to 16 of 16

Thread: Solved: Userform do not load properly

  1. #1
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location

    Solved: Userform do not load properly

    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.
    Thank you for your help

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    I've not looked at your workbook but if you ae hiding the userforms then why not try unloading them instead like this:[VBA]UnLoad Userform1[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    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
    Thank you for your help

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Then i guess you should remove sensitive data ( or change it as it should have the same structure) and post the workbook.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    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
    Thank you for your help

  6. #6
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    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.

    David


  7. #7
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    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
    Thank you for your help

  8. #8
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Oops, forgot to clear the list.

    Try this version.

  9. #9
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    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.
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

  10. #10
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    Sorry gentlemen but both last files fail.
    Thank you both
    Thank you for your help

  11. #11
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    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.
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

  12. #12
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Quote Originally Posted by CharlesH
    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

  13. #13
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    Hi,

    I too noticed that and probably should have mentioned it in my post.
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

  14. #14
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    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.
    Thank you for your help

  15. #15
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    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

  16. #16
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    Good work and thanks for the help David
    Regards, Nick
    Thank you for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •