Post by Andrew sPost by g***@gmail.comHow to make a timer Unload Me/App until 30 minute from loaded App/form.
SOLVED. Thanks
For anyone else that finds this, the easiest solution is to have a timer
fire every 30s (or any value up to but less than 60s) which then used
DateDiff() to calculate the time since it started (using a single Date
variable with "Now" assigned to it) and calling Unload Me if it's
greater than 30 minutes.
Private Started As Date
Private Sub Form_Load()
'Record the current time
Started = Now
End Sub
Private Sub ShutdownTimer_Timer()
'Check if the minute component has increased by 30
If DateDiff("n", Started, Now) > 30 Then Unload Me
End Sub
Note that this could be off by up to 1 minute either way due to the
frequency of the timer and the check not taking into account seconds.
To get around that, you can reduce the timer interval, and check the
number of seconds since it started in the timer.
--
Deanna Earley (***@earlsoft.co.uk, ***@doesnotcompute.co.uk)
(Replies direct to my email address will be printed, shredded then fed
to the rats. Please reply to the group.)