Two simultaneous events ?

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 progreWhat 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 codte.

I'm think its maybe not possible to have the timer event run in tn the
progress bar while the click event is running in thr other form. I tried
DoEvents, but that did not work.



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
 

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

Similar Threads

VBA Export to PDF 0
Progress Bar for timer event 3
VBA - Form Progress 4
Progress BAR 2
Routine too fast for Form to Update? 1
Daily Task Tracking 1
Is there a way to repaint specific controls 1
Progress bar 2

Top