Solved Tracking Progress of a Series of Queries in VBA

RogerCooper

Registered User.
Local time
Yesterday, 21:56
Joined
Jul 30, 2014
Messages
386
I have been using VBA to copy a series of queries into a number of locations on an Excel Spreadsheet.

Code:
Function CopyQueryToExcel(QueryName As String, FileName As String, Worksheet As String, StartingCell As String)
Dim DB As Database
Dim RS As Recordset
Dim Row As Integer
Dim Column As String
Dim NFields As Integer
Dim F As Integer
Dim T As String
Set DB = CurrentDb()
Set RS = DB.OpenRecordset(QueryName)
Row = CLng(Mid(StartingCell, 2, 256))
Column = Left(StartingCell, 1)
With RS
NFields = RS.Fields.Count
SysCmd acSysCmdInitMeter, QueryName, NFields
T = Chr(Asc(Column) + F) & CStr(Row) & ":" & Chr(64 + NFields) & "1000"
Worksheets(Worksheet).Range(T) = ""
.MoveFirst
For F = 0 To NFields - 1
Worksheets(Worksheet).Range(Chr(Asc(Column) + F) & CStr(Row)) = RS.Fields(F).Name
Next
Row = Row + 1
While Not .EOF
For F = 0 To NFields - 1
Worksheets(Worksheet).Range(Chr(Asc(Column) + F) & CStr(Row)) = RS.Fields(F)
Next
Row = Row + 1
.MoveNext
Wend
End With
End Function

So I can see the progress made I used the code.
Code:
SysCmd acSysCmdInitMeter, QueryName, NFields

This shows what query is running, but it continues to display the query name when everything is finished running. How do I remove the meter or is there a better approach to seeing progress.
 

Users who are viewing this thread

Back
Top Bottom