Skip to content

Displaying a Progress Bar

How to insert a progress bar into an Access application.

Q:  Martin Wichmand writes:  “I looked in your site for at simple example with a progressbar – have you made one? You know like the progressbar fx shows how many days since current a day have until a deadline in fx 90 days – with color.”

A:  I haven’t made a code sample with a progress bar, but there is a way to put a progress bar in the status bar of an Access application, using some obscure settings of the SysCmd object.  You have to decide how many units to use, and insert update lines into your code.  If you have lengthy code that can be divided into (say) 5 segments, with an update after each section, here is some sample code for displaying a built-in progress bar with 5 updates:

   ‘Initialize the progress bar (using an arbitrary division of 5 units)

   strProgressBarText = “Creating new Inventory record…”

   varReturn = SysCmd(acSysCmdInitMeter, strProgressBarText, 5)

   'Update the progress bar

   varReturn = SysCmd(acSysCmdUpdateMeter, 1)

   'Update the progress bar

   varReturn = SysCmd(acSysCmdUpdateMeter, 2)

   'Update the progress bar

   varReturn = SysCmd(acSysCmdUpdateMeter, 3)

   'Update the progress bar

   varReturn = SysCmd(acSysCmdUpdateMeter, 4)

   'Update the progress bar

   varReturn = SysCmd(acSysCmdUpdateMeter, 5)

   'Remove the progress bar

   varReturn = SysCmd(acSysCmdRemoveMeter)

You may also want to remove the progress bar from the Exit code of the procedure, in case there is an error.

Note that this progress bar isn't terribly noticeable – if you want something more noticeable, and with more control over its appearance, there is a 3rd-party Progress Meter control available from FMS (it is part of their Total Access Components product).  This control supports color, and is more customizable than the built-in Access progress bar.

About this author