HELP: Progress Meters

  • Thread starter Thread starter terry
  • Start date Start date
T

terry

I have posted a couple of queries on this but im still
stuck.

I have 20 queries which are run by a macro. Because these
take some time because of teh amount of data they work
with I want to display a progress meter while the macro is
running so users can see how far the process is. I have
looked at a couple of examples but cant really understand
how to do it. Has anyone got any easy/more understandable
examples.
Thanks
 
Terry,

I have used progress meters a few times so maybe I can
provide a little help. However, I have not run a meter
from Macros - only Visual Basic.

Creating and displaying the meter is pretty straight
forward. The challenge can be in finding something to
determine the progress and feeding that information to
the meter.

You say you have 20 queries that need to be run. If they
run sequencially and you have some method of determining
when each query starts or finishes you might try
something like this:

Public Sub Run20Queries()
'within the procedure that runs your queries include...
Dim iQuery as Integer 'Number of the query running
Dim iTotal as Integer 'Total number of queries
Dim strMeter as String 'text to disply by Meter
Dim varReturn as Variant 'return of SysCmd statement

Let strMeter = "Query Progress..."
Let iTotal = 20

'initialize the progress meter
varReturn = SysCmd(acSysCmdInitMeter, strMeter, iTotal)

'run each query
For iQuery = 1 to iTotal
'update the Progress Meter
varReturn = SysCmd(acSysCmdUpdateMeter, iQuery)
...Code to run query # iQuery...
Next iQuery

'remove the Progress Meter when done
varReturn = SysCmd(acSysCmdRemoveMeter)

End Sub

To use the progress meter, you need to turn it on and
tell it how much 100% is - in this case 20. Then you need
to derive a value that is some percentage of the total
and repeatedly update the meter with this value. In our
case it is 1/20th or 5% increments. If one query happens
to take much longer to run than another, that particular
5% block will just take longer to change on the meter.
After you have completed your task, you need to turn the
meter off.

Other means of determining the percentages of completion
might include total records in a recordset = 100%. Then
count as each record becomes current and update the meter
with that value.

Keep in mind that the progress meter only has a
resolution of maybe 10-20 segments (I've never counted)
so it doesn't do anything other than increase the
processing if you update your meter more frequently than
every 5% or so. Lets say you had a recordset with 100
records. As you stepped through each record for whatever
purpose, I would only update the meter every 5th record -
or something along those lines.

I hope this is what you were looking for. Good Luck.

-dc
 
Back
Top