Speeding up the progress meter display
This routine is called whenever you want to update the progress meter. Generally, you should call the progress meter only when it's likely to be updated. If you know that you have 1,000 records, you might call the meter every 10 records, but if you have 10,000 records, you might call the meter every 100 records.
Although this code is simple, it isn't the best option. In fact, because this code calls the progress meter for every record, it's much slower than the built-in progress meter. A better approach is to call the progress meter every few records:
If (i / lngCounter) * 100 = Int((i / lngCounter) * 100) Then SetPMeter i / lngCounter End If
The If statement checks to see whether the calculation of the completion percentage is an integer (whole number). This calls the progress meter function (SetPMeter) that moves the progress meter rectangle and displays the percentage completed. It's called only 100 times to move the rectangle; even though the If statement is run 50,000 times, you might wonder why the If statement is faster. The reality is that the If statement takes very few resources to process, but a function that changes the width of a rectangle or control, writes to the screen, and then repaints the screen uses a lot of resources - as evidenced by the time to process falling by 90 percent. Follow these steps to integrate the Progress Meter into your application:
- Import the Progress Meter form into your application.
- Change the code behind the form to interact with your application.
In this tutorial:
- Optimizing Access Applications
- Understanding Module Load on Demand
- Using the .accdb Database File Format
- Distributing .accde Files
- Understanding the Compiled State
- Application's code into a compiled state
- Distributing applications in a compiled or uncompiled state
- Creating a library reference for distributed applications
- Improving Absolute Speed
- Getting the most from your tables
- Getting the most from your queries
- Getting the most from your forms and reports
- Using bitmaps on forms and reports
- Getting the most from your modules
- Using control variables
- Eliminating dead code and unused variables
- Improving Perceived Speed
- Loading and keeping forms hidden
- Speeding up the progress meter display
- Working with Large Access Databases
- Recognizing that compiling and compacting
- Using the decompile option
- Detecting an uncompiled database and automatically recompiling