Click to See Complete Forum and Search --> : how to use Timer control to perform specific task at specific time of the day


Rizwan Atique
September 13th, 2001, 11:05 AM
How can I use timer control if I want to send a file through email everyday at 9 am. here is the code I am trying to implement:
Private Sub tmrSaleCode_Timer()
'MyTime = TimeSerial(10, 19, 0)

If Start1 = 0 Then
Start1 = Timer
End If
Pause = 86400
'Pause1 = 1000
If Timer < Start1 Then
Start1 = Timer
End If
If Timer > (Start1 + Pause1) Then
'If MyTime = Time Then
Start1 = Timer

Module1.TestSndMail
Label2.Caption = "Last Update = " & Now()
'Else
' Start1 = Timer
'End If
End If

End Sub
Thanks.

goddess_spanky
September 13th, 2001, 03:03 PM
I actually do it a little differently, but it is much easier to do (i think).
1. on your form, add a text box and a timer control
2. set the timer interval to 1000 (to update every second or 10000 to update every minute - whichever you prefer)
3. add this event to the timer_timer() event :
me.txtTime.text = format$(time(), "h:mm:ss AM/PM")
where "txttime" is the name of the text box control
4. add this event to the txtTime_Change() event:

private Sub txtTime_Change()
'//add triggered events here.
Dim RunTime1 as string
Dim TOD as string

TOD = Right(me.txtTime.Text, 2)

If TOD = "PM" then
RunTime1 = Right(me.txtTime.Text, 10)
ElseIf TOD = "AM" then
RunTime1 = Right(me.txtTime.Text, 9)
End If

If RunTime1 = "9:00:00 AM" then
MsgBox "It is now 9:00 AM. time to send out the reports!!", vbOKOnly, "Alarm"
End If

End Sub




Let me know if you have any questions or need additional help.

~goddess
goddess_spanky@hotmail.com