timer

I am reading from an access database, i need a timer to triger this reading every 15 minutes, 30,45, and 60 minutes. I have not used timers before so please suggest anything

thanks
sml41Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mcriderConnect With a Mentor Commented:
Add a timer to your program and put this in the timer event:

    Select Case Val(Format(Now, "n"))
        Case 0, 15, 30, 45
            'YOUR EVENT GOES HERE
    End Select

set the timer interval property to 1000
and enable it...

Cheers!
0
 
mcriderCommented:
The example I gave you wil kick off the timer once a second, looking to see if the system clock is at one of the quarter hours...  You can increase to timer intercal property to 60000 and it will check once a minute...



Cheers!
0
 
danlevansCommented:
With an interval of 1000 would you not execute up to60 times for each of the cases?

With a setting of 60000 you might miss depending on timing.

You are limited to 65000 as the max setting so this causes a problem. Most set up a public counter and with a setting of 60000 you count the counter until it gets to 15.

I would be interested in a slick way to do this.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mcriderCommented:
danlevans,

sml41 is looking to fire an event at the quarter hours. Even at setting the timer to 60000 you will not miss the event, because the code looks at the system clock's minute value...

Cheers!
0
 
danlevansCommented:
mcrider

I see what he wants. What you give him is something different. With timer at 1000 it will fire 60 times in one minute. It will find the clock at 15 minutes 60 times!

Now at 60000 if the event fires 60000 one millisecond before 15 goes to 16 you will probably miss it.

Cheers!!
0
 
mcriderCommented:
I was assuming that sml41 would know how to stop an event from firing multiple times... Ok...

using the original code, add a second timer and disable it. then in timer1 Event, do the following:
 
   Select Case Val(Format(Now, "n"))
        Case 0, 15, 30, 45
            Timer1.Enabled = False
            '
            'YOUR EVENT GOES HERE
            '
            With Timer2
                 .Interval = 65535
                 .Enabled = True
            End With
    End Select

And in Timer2's Event:

   Timer2.Enabled = False
   Timer1.Enabled = True


Cheers!
0
 
sonalchouhanCommented:
well i want that the i want the beep after every 30 minutes from the time form is loaded

thanks
sonal
0
 
sml41Author Commented:
thank all
0
All Courses

From novice to tech pro — start learning today.