Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Call a sub when it is a specific hour of the day 1

Status
Not open for further replies.

sfunk

Technical User
Jan 22, 2002
107
US
Hello,

I need to be able to call a Sub during a specific hour of the day withOUT user intervention. It should be called when the hour is equal to (a number). Such as 4 for 4 a.m. It's a timer but the frequency is every 24 hours on what ever hour of the day a variable specifies.

I would like to set the hour to a variable so I can later pull the value in from a database.

It is very UNimportant when during that hour this occures. Accuracy is not important. It could be 4:04 or 4:55. It can be different every time.

Sincerely,
steve

I have heard that the timer can use a lot of CPU. This is going to be running on a server and should use as few resources as possible.
 
I am not sure what you are looking to have the sub do but you may want to just create a small app that contains that sub and just run it as a scheduled task from the control panel, that way windows takes care of the task since the task frequency is only daily. Just a thought. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
I want to perform a check on a database. I have the check stuff written. It is in a Sub called Check_DB. I would like a timer to call Check_DB every 24 hours. I would like to be able to change the hour of the day that the timer fires off the sub.

I hope this is more clear.

Sincerely,
Steve
 
Set these properties...

Timer1.Interval = 45000
Timer1.tag = 0

Private Sub Timer1_Timer()
If Format(Time, "h") = 4 And Timer.tag = 0 then
Do sub...
Timer1.Tag = 1
Elseif NOT Format(Time, "h") = 4
Timer1.tag = 0
End if
End Sub
 
It highlighted the ELSEIF line in red and gave a warning: Expected Then or GoTo.

Could you look at that line and see if there is a typo

Thank you for your help

Cheers,
steve
 
webmigit just probably made a typo. you can add
the "then" clause so it will become

Elseif NOT Format(Time, "h") = 4 THEN
:
:


Hope this helped. [trooper]
 
Sorry I think I need another answer or two.

How does the timer start? I see where I put the call to my Db check. I"m fine with that.

Where do i place the 2 properties. If I keep them where they are in relation to the sub you gave me it places them after the end sub above and I get a warning.

I appologize I am somewhat new to programming and I should have asked for more explicit instructions on what to do with what you gave me.

Cheers,
steve
 
Actually I figured it out.

Thank you for your help.

Sincerely,
steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top