Time Interval Forms

R

Rubie

Hello,

I have three time interval forms setup. The first form is set to 20000,
second form is set to 30000, and the third form is set to 40000 (for testing
purposes only) for now.

Right now form #1(20000) and #3(40000) are bumping into each other when it's
time to run because form #1 runs every (20000).

Is there a way to set the time so that they don't bump into each other?

Appreciate any advice on this one.

Thanks.
 
T

Tom van Stiphout

On Thu, 20 Nov 2008 05:16:07 -0800, Rubie

Why are #1 and #2 not "bumping into each other"?

-Tom.
Microsoft Access MVP
 
B

Brian

They are probably not bumping into each other with respect to starting at the
same exact moment; that could only happen if the forms were opened at exactly
the same moment. More likely, one is not finished when the other attempts to
begin. Here is a partial solution: use a flag to indicate when one of them is
running, and do not start the other one until the first one is done.

Create a public variable: Public TimerProcessRunning as Boolean
As each timer process starts, do this:

Form_Timer
If TimerProcessRunning then Exit Sub
TimerProcessRunning = True
DoMyProcessHere
TimerProcessRunning = False
End Sub

This leaves you with the problem that, when the 40000-interval one does not
run, it does not try again for another 40000 ms, at which time the
20000-interval one may have begun again. You may have to write more complex
code to have it keep trying periodically (i.e. adjust the timer interval)
until no other timer-related process is running.
 
R

Rubie

Thanks for responding. I'm not much of a VB code person. Is there a way to
tell a macro to wait until one interval is done running before starting the
other?
 
B

Brian

I am not aware of any automatic way to do it. I think it would require the
reference to a public variable, and even then, all you can do is either start
or not start a process based on the value. There is no simple "wait until
this is done to start this other thing" macro.

What exactly do the three processes do? Maybe there is a more consolidated
approach to accomplishing those three things that would not require three
separate timers on three separate forms.
 
R

Rubie

Hi Brian,

A table called (LeakTest) was imported when the db was created so that it
will be in place at all times.

Then timer 20000 (runs a macro that imports new external table (LeakTest1
table), timer 30000 (runs a group macro that renames the table (LeakTest1 to
LeakTest), deletes data in a table (Update table), and opens a query
(LeakTest query), timer 40000 (runs a group macro that appends data to a
table (Update table) and closes the query (LeakTest query).

LeakTest query gets data from LeakTest table and Update table gets data from
LeakTest query. That's why I have a table called Update table.

I hope this makes sense. Thanks.
 

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