I have a macro that needs to have a progress meter displayed since it
is long running. I moved the Macro's instructions to a table and pulled
those records into a recordset that is looped through.
PROBLEM -- The form, with a progress meter and labels to inform the
user as to which step of a series of instructions is being done and the
overall progress, seems to lock from repainting after the first
docmd.openquery because the form is never updated until ALL the
openqueries are done.
Any advice out there?
DoCmd.OpenForm "PROGRESS"
Dim frm As Form
Set frm = Forms("PROGRESS")
Dim ctrl As Control
Set ctrl = frm.Controls("lblMessage")
ctrl.Caption = "PLEASE WAIT...." & vbCrLf & "Starting Audit"
Dim lblHdr As Control
Set lblHdr = frm.Controls("lblHeading")
Dim lblTime As Control
Set lblTime = frm.Controls("lblTime")
DoEvents
Set conn = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.Open "select * from AuditOrders", conn, adOpenDynamic,
adLockReadOnly
Dim count As Integer
Dim currCount As Integer
count = 0
currCount = 1
If Not rs.EOF Then
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
End If
If count <= 0 Then Exit Function
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.SetWarnings False
updatemtr 0, count
frm.Repaint
rs.MoveFirst
Do Until rs.EOF
DoEvents
recordval = rs!Value
recordType = rs!TYPE
recordHeading = rs!heading
active = rs!active
lblHdr.Caption = recordHeading
ctrl.Caption = "Executing " & recordval
updatemtr currCount, count
DBEngine.Idle dbRefreshCache
frm.Repaint
Select Case UCase(recordType)
Case "QUERY"
DoCmd.OpenQuery recordval
DoCmd.Close acQuery, recordval
frm.Repaint
Case "REPORT"
'DoCmd.OpenReport recordVal, acViewPreview, , ,
acWindowNormal
Case "CODE"
'Call Val(recordVal)
End Select
Sleep (100)
currCount = currCount + 1
rs.MoveNext
Loop
Exit_Function:
DoCmd.Hourglass False
DoCmd.Echo True
DoCmd.SetWarnings True
MsgBox "AUDIT DONE.", vbOKOnly, "AUDIT COMPLETE"
DoCmd.Close acForm, "PROGRESS"
Exit Function
errorhandler:
If ERR.Description <> "" Then MsgBox "AccuReg Error" & vbCrLf &
ERR.Description, vbOKOnly, "ERROR"
Resume Exit_Function