DoEvents and Form_Timer event 
Author Message
 DoEvents and Form_Timer event

I have an Access app that checks the registry for a value on the Form_Timer
event.  Based on the value read from the registry it calls a function held
in a Code Module.

The event in the code module can take up to 10 seconds to complete (a helll
of a long time in computing terms).  However if the value in the registry
changes before the called function has finished, I want Access to carry on
processing the previous request and then pick up the next value from the
registry.

The code I'm planning to use is:

Private Sub Forn_timer()
While <reg_key_val> = "True"
DoEvents
Wend

Call Function
End Sub

Will Access take this section of code in to account if it is processing the
function code?

thanks
Dann-o



Tue, 28 Jan 2003 03:00:00 GMT  
 DoEvents and Form_Timer event
Dano

If you run the code in your Timer event as you've written it, it could hang
your app.  This is because the timer will fire, and then the code loops
until the registry changes.  But the registry won't change (i'm assuming
that the value is set somewhere else in the app,) because you are stalled in
the code loop.

What you'd rather do is

sub Form_Timer()
If <Reg_value>=True then
    Exit Sub
End if

Call Function

End Sub.

This will let the timer fire off the check a periodic intervals rather than
looping.   Note however that this type of implementation (dependent on the
timer value) will soak up quite a bit of CPU time.
--
Steve Arbaugh
ATTAC Consulting Group
http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm


Quote:
> I have an Access app that checks the registry for a value on the
Form_Timer
> event.  Based on the value read from the registry it calls a function held
> in a Code Module.

> The event in the code module can take up to 10 seconds to complete (a
helll
> of a long time in computing terms).  However if the value in the registry
> changes before the called function has finished, I want Access to carry on
> processing the previous request and then pick up the next value from the
> registry.

> The code I'm planning to use is:

> Private Sub Forn_timer()
> While <reg_key_val> = "True"
> DoEvents
> Wend

> Call Function
> End Sub

> Will Access take this section of code in to account if it is processing
the
> function code?



Wed, 29 Jan 2003 03:00:00 GMT  
 DoEvents and Form_Timer event
Hi Steve

The registry setting is set by another Access application.  The code which I
posted is executed by a hidden Access application.  If this is the case,
then it should be OK to do the loop - yes.  I was also thinking of adding a
counter variable to the while loop and testing the condition, as follows:

Private Sub Forn_timer()
Dim Counter as Integer
Counter = 0
While <reg_key_val> = "True" And Counter <5000
DoEvents
Counter = Counter + 1
Wend

I have set the value to 5000  because the Timer event is called every 5
seconds.  This should prevent{*filter*}.

regards
Dann-o



Fri, 31 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DoEvents not doing any events

2. Multiple Timers, Events Queue, DoEvents Don't Work

3. Timer events have their own DoEvents?

4. Doevents doesnt do events !

5. Help required with Timer Event, DoEvents, Sleep...an easy one

6. DoEvents inside COM event?

7. DoEvents inside TrueDBGrid RowColChange Event

8. Events, Events, alas, wherefore art thou events...

9. Events, Events, alas, wherefore art thou events...

10. Events, Events, alas, wherefore art thou events...

11. Control Event Problem (Post Event after an event is fired)

12. DoEvents and DBEngine.Idle questions

 

 
Powered by phpBB® Forum Software