How to Use a Progress Meter in Access

Visited 1495 times | Submited on 2007-06-05 09:38:22

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.

  1. Initiate the Meter using the acSysCmdInitMeter Action Argument, descriptive text, and a Value Argument which is the Maximum Value of the Meter.
  2. Periodically update the Meter with the acSysCmdUpdateMeter Action Argument and a Value Argument indicating the relative progress of the task at hand.
  3. Remove the Meter using the acSysCmdClearStatus.
  1. 'The following code will loop through all Records in tblEmployee
  2. and Update the value in a newly created Field called [Full Name]
  3. to [FirstName] & " " & [LastName]. The relative completion percentage
  4. of this operation will be displayed in our Progress Meter.
  5. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  6. Dim varReturn, intCounter As Long, dblNum, intNoOfRecs As Long
  7. Set MyDB = CurrentDb()
  8. Set MyRS = MyDB.OpenRecordset("tblEmployee", dbOpenDynaset)
  9. MyRS.MoveLast: MyRS.MoveFirst
  10. intNoOfRecs = MyRS.RecordCount
  11. 'Initialize the Progress Meter, set Maximum Value = intNoOfRecs
  12. varReturn = SysCmd(acSysCmdInitMeter, "Updating...", intNoOfRecs)
  13. Do While Not MyRS.EOF
  14.   With MyRS
  15.     .Edit
  16.       ![Full Name] = ![FirstName] & " " & ![LastName]
  17.         intCounter = intCounter + 1
  18.         'Update the Progress Meter to (intCounter/intNoOfRecs)%
  19.         varReturn = SysCmd(acSysCmdUpdateMeter, intCounter)    .Update
  20.         .MoveNext
  21.   End With
  22. Loop
  23. 'Remove the Progress Meter
  24. varReturn = SysCmd(acSysCmdClearStatus)
  25. MyRS.Close

Source: thescripts.com



Add your comment

Name:(required)
E-mail address:(optional)
Comment:(required)
Repeat the number for validation: (required)

Browse by Tags:


Related Articles:

Text Link Ads

Statistics

Total 296 articles submitted
Latest submission at January 28, 2008 15:13

Feedback

Use this email below to send us your suggestions and feedback. We value your opinion.
info (at) theitarticles.com