Progress Bar for timer event

D

DZ

Hello

I have a progress bar form that I am working on.

The progress bar form has a thin red label that represents the progress of a
loop. The label's width is controled by whatever loop is running in another
form that is performing an action involving a loop that takes some time to
complete. As the loop in the form runs, its loop counter controls the width
of the label in the progress bar form. I am using the repaint method from the
form to repaint the progress bar form on each loop. The label width works
perfectly. It grows as the loop progresses.

Now, I wanted to add an extra feature to the progress bar form, which is a
spinning wheel that works by making 3 overlayed images appear one at a time.
Each image is the same except that each one is at a different point the the
rotation, so by setting the images visible one at a time, the appearance of
rotation is acheived. I want little wheel to simply keep spinning whenever
the progress bar form opens. To do this, I placed code in the progress bar
form. On load, I set Timer interval, then on Timer, each wheel image is made
visible, one at a time.

When I open the progress bar form by itself or from a simple docmd.Open
statement in another form, the little wheel in the progress bar form spins
perfectly.

HERE IS THE PROBLEM

When I open the progress bar form from the procedure in the form that
contains the loop that also controls the label's width, for some reason, the
timer event in the progress bar form does not trigger and wheel does not
spin. But the Load event in the progress bar form triggrers. I can't figure
out why the Timer Event does not trigger.

Here is the code in the form that is running the loop

Do

Forms("Progbar").SetFocus
Forms("Progbar").Form.Controls("lbText").Caption = "Importing " &
intNamedRange & " of " & rs.RecordCount & " named ranges ... Please wait
...."

'Set the label width
Forms("Progbar").Form.Controls("lbp").Width = intTotalLabelWidth /
rs.RecordCount) * intNamedRange
Me.Repaint


Forms("Progbar").Repaint

'Do stuff here

intNamedRange = intNamedRange + 1
lngProgress = lngProgress + 1000
rs.MoveNext

Loop Until rs.EOF

Here is the code that spins the wheel in the Progress Bar form

Private Sub Form_Load()
Me.TimerInterval = 200
End Sub

Private Sub Form_Timer()
Static intState As Integer


'MsgBox intState
If intState = 3 Then
intState = 1
Else
intState = intState + 1
End If


Select Case intState
Case 1

Me.Wheel1.Visible = True
Me.Wheel2.Visible = False
Me.Repaint


Case 2

Me.Wheel1.Visible = False
Me.Wheel2.Visible = True
Me.Wheel3.Visible = False
Me.Repaint
Case 3

Me.Wheel1.Visible = False
Me.Wheel2.Visible = False
Me.Wheel3.Visible = True
Me.Repaint

End Select
End Sub
 
D

DZ

Addendum to my last post

What is happening is that the Timer event in the progress bar form won't
run while the click event in the other form is running the code. I don't
think its possible to have the timer event run while the click event is
running.

Any ideas are welcome
 
S

Stuart McCall

DZ said:
Addendum to my last post

What is happening is that the Timer event in the progress bar form won't
run while the click event in the other form is running the code. I don't
think its possible to have the timer event run while the click event is
running.

Any ideas are welcome

Try inserting a DoEvents statement just before your Loop Until line. This
allows other events (such as timer events) to run each time round the loop.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top