Question

I have a query that I process by looping through each record via VBA. It takes a while to run and the users are impatient. To them it appears that the program has locked up. How do I control the status bar to show the user that the query is in process and working?

I want it to show something like:

TOTAL RECORDS 95551, PROCESSING: 85

The 85 in the above example would increment all the way up until it reached the 95551.

Was it helpful?

Solution

The below should do what it is you are looking for. Visually the progress bar will also move accordingly.

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top