Create a Generic, Reusable Status Meter
Problem
Access allows you to control the built-in status meter using the SysCmd function, but you have no control over the location or appearance of this status meter. How do you create a status meter that you can control?
Solution
You can create a status meter based on an Access form and control it using VBA routines. The status meter is composed of a Rectangle control and a Label control. By updating the Width property of the rectangle, you can control the meter’s progress. Additionally, by updating the Caption property of the label, you can insert messages such as “50% complete”. All the internal workings of the control can be encapsulated (hidden) inside the form using Let and Get property procedures and a global wrapper function.
For an example of a programmatically controlled status bar, open and
run frmTestStatusMeter from 09-10.MDB
(see Figure 9-32). To start the status meter, click the Start
button and frmStatusMeter will pop up. If you want the status meter
to include a Cancel button, check the Include Cancel button checkbox
before clicking the Start button. The status meter will slowly
advance to 100% and then close. If you’ve included a Cancel
button, you can click on it at any time to immediately close the
status meter and notify the calling form (frmTestStatusMeter) that
the cancel has been requested.
Figure 9-32. The frmStatusMeter ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.