Link to home
Start Free TrialLog in
Avatar of urjudo
urjudoFlag for United States of America

asked on

Timer calculation in Access Database

Hi Experts,
I have a question about the calculation time problem in Access Database for Automatically close the database if the database is idle for a period of time.
How do I calaulate for hour(s)?  I would like to set to if idle for 3 hours then close the database automaticaly.

Is this correct for Calculate mintue? -- > ExpiredMinutes = (ExpiredTime / 1000) / 60    

here is my code in the calculation part:

'I set the timer Interval to 1000
ExpiredTime = ExpiredTime + Me.TimerInterval


    ExpiredMinutes = (ExpiredTime / 1000) ' this is for 1 second
    Me.txtIdleTime = ExpiredMinutes
   
If ExpiredMinutes >= 10 Then  ' this is for 10 minutes
   ExpiredTime = 0
   Application.Quit acQuitSaveAll
End If

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Once I had a case of pull some data, perform some actions and continue late at night..I simply put the timer at 1000 ..checked if the time matches or is greater and that's all
Avatar of urjudo

ASKER

@Gustav,
according to your suggested here is the code that I changed to :
ExpiredTime = ExpiredTime + Me.TimerInterval


    ExpiredHours = (ExpiredTime / 1000) / 3600
    Me.txtIdleTime = ExpiredHours
   
If ExpiredHours >= 3 Then  ' this is for 3 hours
   ExpiredTime = 0
   Application.Quit acQuitSaveAll
End If

Is this correct?

Thanks
Seems OK. But haven't tested.
Does it run as expected (set timeout to 1 hour or less)?
Avatar of urjudo

ASKER

@Gustav,
I will tried to test it.  Thanks!
Great! See you in an hour ...
Avatar of urjudo

ASKER

@Gustav,
It works!  Thanks!
Avatar of urjudo

ASKER

Thank you so much Experts!!
You are welcome!