显示状态栏中正在处理的记录

时间:2013-10-18 15:03:24

标签: vba ms-access access-vba ms-access-2000

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

我想要它显示如下:

TOTAL RECORDS 95551, PROCESSING: 85

上例中的85将一直递增,直到达到95551.

1 个答案:

答案 0 :(得分: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