Microsoft Access - Quick and Easy Progress Bar

Within Access, there are times when a process is slow-running and appears to be non-responsive. The most logical way to convince a user to wait patiently is to use a progress bar. The question is how to do this within Access with as little as possible effort.

One quick and easy way to add a progress bar is to take advantage of the seldom-used SysCmd method. (SysCmd has several uses, but falls out of the scope of this article.) All it takes to add a progress bar is to place three lines of VBA code:

1. SysCmd acSysCmdInitMeter, "Updating: ", 1000   ' Initialize Progress bar
2. SysCmd acSysCmdUpdateMeter, Counter            ' Update Progress Bar
3. SysCmd acSysCmdRemoveMeter                     ' Remove Progress Bar

In the first line of code, SysCmd takes three parameters, the second being a text message that appears before the bar, and the third being a full counter value. This full counter value is the number of steps that represents a completed task.

The second line of code's second parameter is a counter value, which represents the current state of progress completion. The progress bar will reflect the percentage that this counter value is of the full counter value specified in the first line of code.

The three lines of code are inserted into the following snippet, and will generate the progress bar:

Dim Counter As Integer

SysCmd acSysCmdInitMeter, "Updating: ", 1000
For Counter = 1 To 1000
    SysCmd acSysCmdUpdateMeter, Counter
    Code
     .
     .
    Code
Next Counter
SysCmd acSysCmdRemoveMeter

Figure: Progress bar on an MS Access form

That is all it takes to code the progress bar. Too easy!