0

我有一个查询,我通过 VBA 循环遍历每条记录来处理该查询。运行需要一段时间,用户不耐烦。在他们看来,该程序已被锁定。如何控制状态栏以向用户显示查询正在处理并且正在工作?

我希望它显示如下内容:

TOTAL RECORDS 95551, PROCESSING: 85

上例中的 85 会一直递增,直到达到 95551。

4

1 回答 1

4

下面应该做你正在寻找的东西。视觉上,进度条也会相应移动。

Dim tempRN AS Long, tempRT AS Long

tempRN= 1

'Get the total number of records that you need to work with and assign to tempRT

Application.SysCmd acSysCmdInitMeter, "TOTAL RECORDS " & tempRT & ", PROCESSING: " & tempRN, tempRT

Do While .......
  'Do whatever it is you need to do

  tempRN = tempRN + 1
  Application.SysCmd acSysCmdRemoveMeter
  Application.SysCmd acSysCmdInitMeter, "TOTAL RECORD COUNT " & tempRT & ", PROCESSING: " & tempRN, tempRT
  Application.SysCmd acSysCmdUpdateMeter, tempRN
Loop

Application.SysCmd acSysCmdRemoveMeter
于 2013-10-18T15:09:35.043 回答