I have made an alarm clock, and implemented the function given in the first link. I use it to close down windows media player. after a specified amount of time has passed. But for some reason, access periodically freezes on me. Sometimes the code works fine, and other times it locks up the whole application. Can anyone see a mistake in my code which would cause access to lock up?
(I have the timer set to 1000 so the timer event runs every second)
Private Sub Form_Timer()
CurrentTime = Time()
If Not IsNull(AlarmTime) Then
Dim theHour As String
Dim theMin As String
Dim AlarmHour As String
Dim AlarmMin As String
Dim StopHour As String
Dim StopMinute As String
theHour = Hour(CurrentTime)
theMin = Minute(CurrentTime)
If Not IsNull(AlarmTime) Then AlarmHour = Hour(AlarmTime)
If Not IsNull(AlarmTime) Then AlarmMin = Minute(AlarmTime)
If Not IsNull(StopTime) Then StopHour = Hour(StopTime)
If Not IsNull(StopTime) Then StopMinute = Minute(StopTime)
If theHour = AlarmHour And theMin = AlarmMin And Check = 0 Then
FollowHyperlink "T:\Sups Only\Computer Research/song.m3u"
Check = -1
StopTime = DateAdd("n", 5, AlarmTime)
ElseIf theHour = StopHour And theMin = StopMinute And Check = -1 Then
fCloseApp ("Media Player 2")
End If
End If
End Sub
Private Sub Set_Click()
AlarmTime = InputBox("What time do you want to set the alarm for?", "Set Alarm", , 50, 100)
Check = 0
End Sub
Private Sub Snooze_Click()
fCloseApp ("Media Player 2")
AlarmTime = DateAdd("n", 3, CurrentTime)
Check = 0
End Sub