Many Access Users fail to realize that it has a built-in Progress Meter that can display the relative completion percentage of various processes. It is fairly limited, but nonetheless, does provide visual feedback indicating the percent completion of a certain task. The Meter itself, when activated, rests on the left hand corner of the Status Bar and is controlled via the SysCmd() Method. It is straightforward, simple to use, and involves only 3 steps to implement it, These steps are listed below. Following these steps, a code segment involving the updating of a Field within a Recordset, will demonstrate its use.
- Initiate the Meter using the acSysCmdInitMeter Action Argument, descriptive text, and a Value Argument which is the Maximum Value of the Meter.
- Periodically update the Meter with the acSysCmdUpdateMeter Action Argument and a Value Argument indicating the relative progress of the task at hand.
- Remove the Meter using the acSysCmdClearStatus.
- 'The following code will loop through all Records in tblEmployee
-
and Update the value in a newly created Field called [Full Name]
-
to [FirstName] & " " & [LastName]. The relative completion percentage
-
of this operation will be displayed in our Progress Meter.
-
-
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
Dim varReturn, intCounter As Long, dblNum, intNoOfRecs As Long
-
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset("tblEmployee", dbOpenDynaset)
-
-
MyRS.MoveLast: MyRS.MoveFirst
-
intNoOfRecs = MyRS.RecordCount
-
- 'Initialize the Progress Meter, set Maximum Value = intNoOfRecs
-
varReturn = SysCmd(acSysCmdInitMeter, "Updating...", intNoOfRecs)
-
-
Do While Not MyRS.EOF
-
With MyRS
-
.Edit
-
![Full Name] = ![FirstName] & " " & ![LastName]
-
intCounter = intCounter + 1
-
'Update the Progress Meter to (intCounter/intNoOfRecs)%
-
varReturn = SysCmd(acSysCmdUpdateMeter, intCounter) .Update
-
.MoveNext
-
End With
-
Loop
-
- 'Remove the Progress Meter
-
varReturn = SysCmd(acSysCmdClearStatus)
-
-
MyRS.Close
NOTE: If updating a large Recordset, you may wish to periodically relinquish control to the Windows Environment using DoEvents. If anyone is interested in how to do this, please let me know,