patriciaxxx
Programmer
I have the code below which works as follows:
On the form when you click the command button it sets the Forms Timer Interval to 3 seconds and then calls a function. The function takes a varying time to run depending on how much it does. The DoEvents makes sure it completes before moving on.
The Forms Timer event increments the meter and resets it after the Timer Interval has elapsed.
My problem is, while this all works, it doesn’t work how I would like it to.
What I mean is, the duration of the Meter is currently determined by the Timer Interval set to 3 seconds [highlight #EDD400]but I want it last for however long it takes the ‘Call WorkArounds” to run.[/highlight]
I can’t work out a way to do this, usually I increment progress meters using loops but there are no loops in any of the code to use which is why I’m using the Forms Timer.
Any help would be much appreciated.
On the form when you click the command button it sets the Forms Timer Interval to 3 seconds and then calls a function. The function takes a varying time to run depending on how much it does. The DoEvents makes sure it completes before moving on.
The Forms Timer event increments the meter and resets it after the Timer Interval has elapsed.
My problem is, while this all works, it doesn’t work how I would like it to.
What I mean is, the duration of the Meter is currently determined by the Timer Interval set to 3 seconds [highlight #EDD400]but I want it last for however long it takes the ‘Call WorkArounds” to run.[/highlight]
I can’t work out a way to do this, usually I increment progress meters using loops but there are no loops in any of the code to use which is why I’m using the Forms Timer.
Any help would be much appreciated.
Code:
Option Compare Database
Option Explicit
Private Sub cmdSaveChanges_Click()
Me.TimerInterval = 3000
DoEvents
Call WorkArounds
Me.cboLinkedTables.Enabled = True
Me.cboLinkedTables.SetFocus
Me.cmdSaveChanges.Enabled = False
End Sub
Private Sub Form_Timer()
Static intCounter As Integer
intCounter = intCounter + 1
If intCounter <> 21 Then Me.Controls("Box" & intCounter).Visible = True
If intCounter <> 21 Then Me.lblStatus.Caption = intCounter * 5 & "% Complete"
If intCounter = 21 Then
Me.lblStatus.Caption = ""
Me.TimerInterval = 0
intCounter = 0
Dim i As Integer
For i = 1 To 20
Me.Controls("Box" & i).Visible = False
Next i
End If
End Sub