Part IV: Professional Database Development
870
The first step for using the percent meter is initializing the meter by calling the SysCmd function:
ReturnValue = SysCmd(acSysCmdInitMeter, “Creating Records”, lngCounter)
acSysCmdInitMeter is an Access constant that tells the function to initialize the meter. The
second parameter is the text to appear at the left side of the meter. Finally, the last value is the
meter’s maximum value (in this case, 100); for example, if you were iterating through a loop of
50,000 records, you might set this value to 50,000. Then you can pass the record count at any
time to the SysCmd function and Access decides what the meter shows.
After the meter is initialized, pass a value to update the meter. Call the SysCmd function again and
pass it the acSysCmdUpdateMeter constant and the new meter value. Remember: The value
that you pass to the function is not necessarily the percent displayed by the meter — it can be the
number of records processed or any number that represents a percentage from 1 to 100. For exam-
ple, the meter displays 25 percent if 50,000 records are being processed and the update value is
12,500.
ReturnValue = SysCmd(acSysCmdUpdateMeter, i)
Remove the meter from the status bar after all the records are processed:
ReturnValue = SysCmd(acSysCmdRemoveMeter)
The progress meter displayed in the status bar is shown in Figure 24.11.
FIGURE 24.11
The Access status-bar progress meter
Creating a progress meter as a pop-up form
Open ProgressMeterCallingEveryRecord and click the Search button to see a progress
meter implemented as a pop-up form. The bar grows from 0 percent to 100 percent.
The Progress Meter form in progress is shown in Figure 24.12.
FIGURE 24.12
A graphical progress meter