Progress Bar.. (1 Viewer)

Number11

Member
Local time
Today, 18:11
Joined
Jan 29, 2020
Messages
228
Hi, so i am looking for some code to run a progress bar form at the start of my code and then finish when the code as completed any ideas?
 

arnelgp

error reading drive A:
Local time
Tomorrow, 02:11
Joined
May 7, 2009
Messages
11,121
you can use syscmd to instantiate the "Meter" (syscmd acSysCmdInitMeter google its usage).
 

Minty

AWF VIP
Local time
Today, 18:11
Joined
Jul 26, 2013
Messages
7,760
Look at the bottom of this thread for some existing posts about progress bars.
 

Isaac

Lifelong Learner
Local time
Today, 10:11
Joined
Mar 14, 2017
Messages
3,201
 

Number11

Member
Local time
Today, 18:11
Joined
Jan 29, 2020
Messages
228
umm haven't really got much done here, so i would like a progress form to show between the time the VBA code is running and then to stop once call the code as finished. Look at the links but seems to only show a process bar that is running on a timer, and i dont know who long the code will take to run so need to look for some other solution....
 

Minty

AWF VIP
Local time
Today, 18:11
Joined
Jul 26, 2013
Messages
7,760
Unless you have a fixed number of steps that are run through a progress bar won't know how far through the process (whatever that is) it is.

If you have a loop going through 100 or 1000 records, then you have something to work with.
If you have 10 stages in your process then you have something to increment a bar with 10 % at a time.

if you have a single process that sometimes takes 20 seconds but next time take 2 minutes I'm not sure how you would expect access and therefore your progress bar to know.
 

Number11

Member
Local time
Today, 18:11
Joined
Jan 29, 2020
Messages
228
think i will just have a form open and then close it just before code has finished
 

isladogs

CID VIP
Local time
Today, 18:11
Joined
Jan 14, 2017
Messages
14,227
umm haven't really got much done here, so i would like a progress form to show between the time the VBA code is running and then to stop once call the code as finished. Look at the links but seems to only show a process bar that is running on a timer, and i dont know who long the code will take to run so need to look for some other solution....
If you are referring to my example app, it states clearly:
For the purposes of the example database, a form timer event is used to show progress
However, in normal usage, a timer event isn't used.
Instead the progress bar is updated after each action is completed. So the code goes something like this:

Code:
 'start progress bar code
    Dim iCount As Integer
    iCount = 10 'change to match the number of events
    SetupProgressBar

    'run first event
    Procedure1 'this could be a sub, function or a query
    UpdateProgressBar

    'run second event
    Procedure2
    UpdateProgressBar     

    '....

   'run final event
    Procedure10
    UpdateProgressBar

    'remove progress bar now it has completed
    HideProgressBar

The code is normally run either from a button click or in the Form_Load event
 
Last edited:

Isaac

Lifelong Learner
Local time
Today, 10:11
Joined
Mar 14, 2017
Messages
3,201
umm haven't really got much done here, so i would like a progress form to show between the time the VBA code is running and then to stop once call the code as finished. Look at the links but seems to only show a process bar that is running on a timer, and i dont know who long the code will take to run so need to look for some other solution....
Why don't you explain to us, WHAT your code does and how it runs, and explain specifically what would be the logic in your code that would tell any Progress Bar what percent complete, to show? That way we don't have to guess.

For example, the link I posted contains a progress bar approach that depends on a known number of Loop iterations. I would hazard a guess that is probably the most common approach dependency as it makes the most sense. A slight "variation" of that same thing would be a "known" number of tasks (i.e., your code is going to do Thing1, then Thing2, then Thing3), and you update the Progress Bar to show 0, 30%, whatever, during it.

IMO but the first step is to make the Progress Bar itself, and create a small Sub or Function that can be called on demand which:
1) either Shows or Hides the progress bar
2) updates the caption, if you want
3) displays the % width of the bar control itself

And can be called like ShowProgress(True, "Processing", .7)

Then you look at your code and determine if the progress is predictable and makes sense to show an incrementing bar - it may not.

Not all code lends itself and makes sense to run a progress bar. As Microsoft has generously demonstrated for us by continually showing progress bars on Windows tasks that make no sense, like ones that show 95% for the entire time - That's an example of someone making a progress bar where none was called for, and a rotating GIF might have made more sense. :)
 

Users who are viewing this thread

Top Bottom