Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Use a Progress Meter in Access

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#1   May 12 '07
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.

Expand|Select|Wrap|Line Numbers
  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.  
  6. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  7. Dim varReturn, intCounter As Long, dblNum, intNoOfRecs As Long
  8.  
  9. Set MyDB = CurrentDb()
  10. Set MyRS = MyDB.OpenRecordset("tblEmployee", dbOpenDynaset)
  11.  
  12. MyRS.MoveLast: MyRS.MoveFirst
  13. intNoOfRecs = MyRS.RecordCount
  14.  
  15. 'Initialize the Progress Meter, set Maximum Value = intNoOfRecs
  16. varReturn = SysCmd(acSysCmdInitMeter, "Updating...", intNoOfRecs)
  17.  
  18. Do While Not MyRS.EOF
  19.   With MyRS
  20.     .Edit
  21.       ![Full Name] = ![FirstName] & " " & ![LastName]
  22.         intCounter = intCounter + 1
  23.         'Update the Progress Meter to (intCounter/intNoOfRecs)%
  24.         varReturn = SysCmd(acSysCmdUpdateMeter, intCounter)    .Update
  25.         .MoveNext
  26.   End With
  27. Loop
  28.  
  29. 'Remove the Progress Meter
  30. varReturn = SysCmd(acSysCmdClearStatus)
  31.  
  32. 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,



Newbie
 
Join Date: Aug 2007
Posts: 1
#2   Aug 22 '07

re: How to Use a Progress Meter in Access


I am using syscmd for the meter....if I do not stay on the screen and go to another application, when I try to come back to the screen it does not update the meter anymore....I have the same thing with msgbox.
Familiar Sight
 
Join Date: Apr 2007
Location: Lebanon
Posts: 211
#3   Aug 31 '07

re: How to Use a Progress Meter in Access


Very useful code thank you

I'm using a full screen form am I able to change the place of the update meter ? for example having it as msgbox in my form ..



I'm interesting in DoEvents because I'm using a very large recordset (more than 1000 000 records/ table ) I'm always have delay if I want to select a record in the recordset or navigate using loop ...


Can u explain for me the best way to search a value in a very large recordset ?
Does memories (ram) || cash memory || CPU frequencies || system heat are factors to change the speed of getting a value in a recordset ?
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#4   Aug 31 '07

re: How to Use a Progress Meter in Access


Quote:

Originally Posted by wassimdaccache

Very useful code thank you

I'm using a full screen form am I able to change the place of the update meter ? for example having it as msgbox in my form ..



I'm interesting in DoEvents because I'm using a very large recordset (more than 1000 000 records/ table ) I'm always have delay if I want to select a record in the recordset or navigate using loop ...


Can u explain for me the best way to search a value in a very large recordset ?
Does memories (ram) || cash memory || CPU frequencies || system heat are factors to change the speed of getting a value in a recordset ?

The most efficient and fastest way to search for a value in a very large Recordset is by using the Seek() Method. It must, however, be based on a Table Type Recordset. Everything you mentioned is more than likely a factor that effects the speed with which searches can be done, but one of the most critical factors, in my opinion, is whether or not the Field is Indexed.
rcollins's Avatar
Familiar Sight
 
Join Date: Aug 2006
Location: Grand Junction, CO
Posts: 233
#5   Oct 10 '07

re: How to Use a Progress Meter in Access


Here is the error I am getting now: "You can't reference a property or method for a control unless the control has the focus."
Here is my exact code for picking from two choises. I only get this error on the first choice, but don't get anything in the text box with the second one.
Expand|Select|Wrap|Line Numbers
  1. Private Sub StandardizedAllocation_AfterUpdate()
  2. If StandardizedAllocation.Text = "HOUSE MEETINGS:" Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
  3. If StandardizedAllocation.Text = "MD Appt.Prep:" Then StandardizedAllocationSumm.Text = "Case file reviewed for pending medical appointment.  Plan of care reviewed and updated."
  4.  
  5. End Sub
  6.  
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#6   Oct 10 '07

re: How to Use a Progress Meter in Access


Quote:

Originally Posted by rcollins

Here is the error I am getting now: "You can't reference a property or method for a control unless the control has the focus."
Here is my exact code for picking from two choises. I only get this error on the first choice, but don't get anything in the text box with the second one.

Expand|Select|Wrap|Line Numbers
  1. Private Sub StandardizedAllocation_AfterUpdate()
  2. If StandardizedAllocation.Text = "HOUSE MEETINGS:" Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
  3. If StandardizedAllocation.Text = "MD Appt.Prep:" Then StandardizedAllocationSumm.Text = "Case file reviewed for pending medical appointment.  Plan of care reviewed and updated."
  4.  
  5. End Sub
  6.  

You use the Text property to set or return the text contained in a Text Box or in the text box portion of a Combo Box. It is a Read/write String. To set or return a control's Text property, the Control must have the focus, or an error occurs. If you are just concerned with setting/retrieving the value in the Control itself, then adjust your code to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StandardizedAllocation_AfterUpdate()
  2. If Me![StandardizedAllocation] = "HOUSE MEETINGS:" Then   
  3.   Me![StandardizedAllocationSumm] = "Consult with direct care staff ongoing medical concerns and plan of care."
  4. ElseIf Me![StandardizedAllocation] = "MD Appt.Prep:" Then   
  5.   Me![StandardizedAllocationSumm] = "Case file reviewed for pending medical appointment.  Plan of care reviewed and updated."
  6. Else
  7.   'not sure what you want to do here, if anything
  8. End If
  9. End Sub
rcollins's Avatar
Familiar Sight
 
Join Date: Aug 2006
Location: Grand Junction, CO
Posts: 233
#7   Oct 10 '07

re: How to Use a Progress Meter in Access


Awesome, sorry I posted this in the wrong place, but working on three databases at the same time. Worked perfect.
Reply