OnTimer Events

Adrian510

Registered User.
Local time
Today, 08:41
Joined
Nov 24, 2005
Messages
38
I need to achieve different results at different points in my TAB controlled form depending on the user input (or lack of it) after a varying lengths of time. For example if there is no user input after 5 minutes i need to set of an alarm and MsgBox to prompt for it except when "Break" has been selected in which case the alarm should go off after 22 minutes. I have been searching the site and MSDN for suitable ways of achieving it and if i had seperate opening forms i think i could but as i mentioned its 1 form with pages, what i was thinking of was something along the lines of

Dim SetTimerInterval As Interger

Private Sub Form_Load()
TimerInterval = SetTimerInterval
End Sub


Sub Form_Timer()

Beep

End Sub

Where i would somehow reset the value of SetTimerInterval depending on the situation, users have to click command buttons so i was thinking of using these in some way?

Anyway its one of those I know it can be done but i am not sure of the best way situations i was hoping that somebody could point me in the direction of a good example or could give me some advice.

Regards

Adrian
 
Something like this?

Code:
Const lngBroken As Long = 1320000 ' 22 minutes
Const lngUnbroken As Long = 300000 ' 5 minutes

Private Sub Form_Current()
    If Me.Checkbox Then
        Me.TimerInterval = lngBroken
    Else
        Me.TimerInterval = lngUnbroken
    End If
End Sub

Private Sub Form_Timer()
    MsgBox "HURRY UP!!!"
End Sub

Private Sub CheckBox_AfterUpdate()
    Call Form_Current()
End Sub
 
Last edited:
Thanks for the reply its appreciated as I know that this can seem like a pretty basic question so not very interesting to a lot of people but to me it was a bit of a headache (we all have to start somewhere) and i am trying to pick up good practice from the outset rather than get into bad habits.

Here's what i ended up with in the end which works but again may not have been the best approach (I have my reference book out and am studying yours).

Any advice on a good book or web related referance material i could use? or something better for my alarm than Beep? To push my luck further with a 3rd question I am also trying to set an alarm off on a seperate PC when the Alarm goes off and can't use email. My first thought was some sort of bollean value for Alarm in a linked table and have the other PC requery at a set period but somebody whispered net call in my ear (which I don't know anything about) and so I steer in the right direction would be good.

Thanks again

Take it easy

Adrian


Code:
Dim AssignTimerValue As String

Private Sub Form_Load()

AssignTimerValue = 0

End Sub



Private Sub Form_Timer()

Call Alarm

End Sub



Private Sub lstDTeason_AfterUpdate()

Select Case lstDTeason

    Case "Break"
    AssignTimerValue = "1000"
    
    Case "Staff"
    AssignTimerValue = "5000"
    
    Case Else
    AssignTimerValue = "0"

End Select

TimerInterval = AssignTimerValue

End Sub


Sub Alarm()

Beep

End Sub
 
Last edited by a moderator:

Users who are viewing this thread

Back
Top Bottom