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.
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,
- Initiate the Meter using the acSysCmdInitMet er Action Argument, descriptive text, and a Value Argument which is the Maximum Value of the Meter.
- Periodically update the Meter with the acSysCmdUpdateM eter Action Argument and a Value Argument indicating the relative progress of the task at hand.
- Remove the Meter using the acSysCmdClearSt atus.
Code:
[B]'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.[/B] 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 [B]'Initialize the Progress Meter, set Maximum Value = intNoOfRecs varReturn = SysCmd(acSysCmdInitMeter, "Updating...", intNoOfRecs)[/B] Do While Not MyRS.EOF With MyRS .Edit ![Full Name] = ![FirstName] & " " & ![LastName] intCounter = intCounter + 1 [B] 'Update the Progress Meter to (intCounter/intNoOfRecs)% varReturn = SysCmd(acSysCmdUpdateMeter, intCounter)[/B] .Update .MoveNext End With Loop [B]'Remove the Progress Meter varReturn = SysCmd(acSysCmdClearStatus)[/B] MyRS.Close
Comment