+ Reply to Thread
Results 1 to 6 of 6

Userform initializes more than once.

  1. #1
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120

    Userform initializes more than once.

    I have code in Module1 that calls OpenFileUF.Show (my userform). the code in the userform has property code so that I can Get and Let. In cdbOK_Click, I have Unload Me to unload the userform. In Module1, I call OpenFileUF.sPath sometime after I show the userform to get a path string. when i call this, the userform re-initializes. because it re-initializes, it replaces all the data that the user inputted when it was shown and therefore returns the wrong sPath string.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Unload releases the form from memory, and so clears all the data not set a design time.

    Try the Hide method instead of Unload. The form will retain its data while hidden, and not trigger the Initialize event when shown.

  3. #3
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120
    thats what i was thinking but is that the proper way to get data out of a userform after the user clicks OK?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Pardon ...?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Try this approach. use a object variable to reference the userform.
    You Hide the userform when done, which returns control to the Test routine.
    Then once you have the information from the userform you can unload and remove from memory.

    Module code
    Please Login or Register  to view this content.
    Userform contains 1 commandbutton and read-only property to return current folder.
    Userform code
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120
    that seems to work. thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Execute code from auto generated buttons in a userform
    By Tellus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2008, 09:07 AM
  2. Editing columns through Userform; "Dictionary Editor"
    By wali in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-04-2008, 03:44 PM
  3. Keep Modal UserForm Alive after closing 2nd userform using 2007?
    By ShredDude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2008, 03:12 PM
  4. Why is my UserForm Pausing Procedure?
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2007, 05:20 PM
  5. UserForm Code Question/Help
    By peter.thompson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2006, 02:29 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1