次の方法で共有


ステータス バーの進行状況メーターを使用する

このトピックでは、 SysCmd メソッドを使用して、既知の期間またはステップ数を持つ操作の進行状況を視覚的に表す進行状況メーターをステータス バーに作成する方法について説明します。

ステータス バー上の進行状況インジケーターを操作するために、SysCmd メソッドの action 引数に指定して使用できる 3 つの組み込み定数 があります。 次の表はそれらの組み込み定数についての説明です。

組み込み定数 説明
acSysCmdInitMeter 進行状況インジケーターを初期化します。 プロセスが取得する最大値は、 SysCmd メソッドの value 引数で指定します。
acSysCmdUpdateMeter 進行状況インジケーターを更新します。 完了までの現在の進行状況を表す数式を、SysCmd メソッドの value 引数で指定します。
acSysCmdRemoveMeter 進行状況インジケーターを消去します。

次のプロシージャでは、SysCmd メソッドを使用して進行状況インジケーターを更新し、[Customers] テーブルのデータを [イミディエイト] ウィンドウに順次出力する処理の進行状況を示します。

Sub ProgressMeter() 
   Dim MyDB As DAO.Database, MyTable As DAO.Recordset 
   Dim Count As Long 
   Dim Progress_Amount As Integer 
    
   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. 
    SysCmd acSysCmdInitMeter, "Reading Data...", Count 
 
   ' Enumerate through all the records. 
   For Progress_Amount = 1 To Count 
     ' Update the progress meter. 
      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] & "'") 
                   
     ' Go to the next record. 
      MyTable.MoveNext 
   Next Progress_Amount 
 
   ' Remove the progress meter. 
   SysCmd acSysCmdRemoveMeter 
         
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。