a makeshift progress bar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • normalice
    New Member
    • Dec 2010
    • 28

    #1

    a makeshift progress bar

    Hello, I wrote some code that loops over several thousands .CSV files, imports them into a remote table, alters the data to be compatible with the database, and stores them in another remote table. After every file it also checks both the import to and export to tables to ensure they are not approaching the size limit. If the export table is approaching the size limit, it simply creates a new table and starts writing to that. If the import table is approaching the size limit, it compacts the table (the import table is cleared out before every import).

    Anyway, between each successful .CSV file upload, I would like to update a text box ,on the form, with the total size of the files thus far successfully compiled, combined with the starting size of the entire folder with .CSV files in it, and of course an expected time of finish.

    This is all very easy math, and I have it set to do exactly what I want it to, except it doesn't actually refresh the values of these text boxes until the code is finished. Is there a way to get it to do so without prompting the user for some type of input?

    The bottom line is exactly that. I could post the code if someone really thinks it would be useful to know, but there's tons of it. Here's some fake pseudo-code that is essentially the same thing I want done:

    Code:
    x = 1
    while x <= one hundred trillion
     if x mod one trillion = 0 then
      [Text0] = x / one trillion 
     end if
     x = x + 1
    wend
    currently, if i were to run this in access, the form would "freeze up" while the code is running, and then display 100 at the end. I would like it to display the count (1.... 2..... 3.... et cetera).
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Interface updates only occur after the code has finished running. To get what you want, you will need to use the timer event of the form and track the progress using global variables.

    Comment

    • normalice
      New Member
      • Dec 2010
      • 28

      #3
      does the timer event code work while other code is running?

      i didn't know that.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        It won't run while other code is running. If code is currently running, it will trigger and then go in a queue to wait its turn. Therefore, you will have to move the csv file upload into the timer event and track which file you're on using global variables.

        Comment

        • munkee
          Contributor
          • Feb 2010
          • 374

          #5
          Could you just add a line in to your code to requery the textbox through each iteration? I haven't ever had to do what you are explaining but it is what I would be trying if I were.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Requerying a textbox results in an interface update. The results won't show until the code returns from execution.

            Comment

            • RuralGuy
              Recognized Expert Contributor
              • Oct 2006
              • 375

              #7
              Have you tried putting some DoEvents to allow the Tasker to run?

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                I created a simple Demo for you that will indicate how you can visually display the progress of an ongoing process with nothing more than a couple of Label Controls. Download the Attachment, and if you have any questions, please feel free to ask.
                Attached Files

                Comment

                Working...