Consulting

Results 1 to 4 of 4

Thread: Sleeper: Memory Issue

  1. #1

    Sleeper: Memory Issue

    Hi, i have no way of explaining this clearly so i will try my best.
    I developed a VBA add-on that works with a userform. I access the userform from a button created in workbook_open code. The thing is the userform can read data form the sheets and create a structure ("type ...."). from the userform i can print some reports and modify the data to change the reports. Sometimes, moslty after printing a report, if I close the userform and then call it again form the button, all the public variables i had created and read before is lost and also all the changes i created earlier. Is there any way the public variables "survive" several closing and openings of the userform?
    hope its clear enough.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Where are the piublic variab les defined, in a normal code module, or in the userform class module?


    How do you clode the form, with Unload or Hide?

  3. #3
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    If you declare the variables you need as Public in a standard module they will available while the project is active.
    As xld indicates,you could also have varibles declared in the user form and then hide/show the userform from the button (load on Workbook_Open and unload on Workbook_close.) This keeps it in memory so if it's used often there may be advantage to this.
    K :-)

  4. #4
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    What about saving the variables to a file on disk, and reading them back the next time?

Posting Permissions

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