Microsoft KB Archive/210474

= ACC2000: How to Use the Status Bar Progress Meter =

Article ID: 210474

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210474



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
This article shows you how to use the SysCmd function in Microsoft Access to create a progress meter on the status bar that gives a visual representation of the progress of an operation that has a known duration or number of steps.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The syntax of the SysCmd function is

SysCmd( [ ] [ ])

where   is a numeric expression identifying the required action. The expression is one of the following:   Intrinsic Constant     Value   Action acSysCmdInitMeter       1     Initialize progress meter acSysCmdUpdateMeter     2     Update progress meter acSysCmdRemoveMeter     3     Remove progress meter   is a string expression providing the message that appears to the left of the progress meter on the status bar.  is a numeric expression that controls the display of the meter. This is required when the action is acSysCmdInitMeter or acSysCmdUpdateMeter and invalid otherwise.

When the action is acSysCmdInitMeter,  establishes the maximum value the process should attain, that is, when the meter indicates 100 percent.

When the action is acSysCmdUpdateMeter,  is used to calculate and update the progress toward completion on the meter.

NOTE: The SysCmd function returns NULL when it is displaying a progress meter.

How to Use SysCmd in a Function
To use SysCmd to display a progress meter, follow these steps:  CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

 Start Microsoft Access and open the sample database Northwind.mdb.</li> In the Database window, click Modules, and then click New.</li>  Type the following line in the Declarations section if it is not already there: Option Explicit </li> Save the module as Meter Test.</li>  Type or paste the following procedure: Function Meter Dim MyDB As DAO.Database, MyTable As DAO.Recordset Dim Count As Long Dim Progress_Amount As Integer, RetVal As Variant Set MyDB = CurrentDb Set MyTable = MyDB.OpenRecordset("Customers")

' Move to last record of the table to get the total number of records. MyTable.MoveLast Count = MyTable.RecordCount

' Move back to first record. MyTable.MoveFirst

' Initialize the progress meter. RetVal = SysCmd(acSysCmdInitMeter, "Reading Data...", Count)

' Enumerate through all the records. For Progress_Amount = 1 To Count ' Update the progress meter. RetVal = SysCmd(acSysCmdUpdateMeter, Progress_Amount) 'Print the contact name and number of orders in the Immediate window Debug.Print MyTable![ContactName]; _ DCount("[OrderID]", "Orders", "[CustomerID]='" & MyTable![CustomerID] & "'")

' Goto the next record. MyTable.MoveNext Next Progress_Amount

' Remove the progress meter. RetVal = SysCmd(acSysCmdRemoveMeter) End Function </li> Save and close the module.</li> In the Database window, click Forms, and then click New.</li> In the New Form dialog box, click OK to create a new form in Design view without selecting any table or query.</li> If the Properties sheet is not visible, on the View menu, click Properties.</li> On the Properties sheet, click Event, click On Open, and then select Event Procedure.</li>  Click the Build button and, in the Visual Basic Editor, type the following procedure: Private Sub Form_Open(Cancel As Integer)

Meter

End Sub </li> Quit the Visual Basic Editor, and then save and close the Test Meter form.</li> In the Database window, click Forms, select Test Meter, and then click Open.

Notice the progress meter on the status bar.</li></ol>

<div class="references_section">