Avatar of urjudo
urjudo
Flag 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,
* CodingMicrosoft Access

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
John Tsioumpris

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
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
Gustav Brock

Seems OK. But haven't tested.
Does it run as expected (set timeout to 1 hour or less)?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
urjudo

ASKER
@Gustav,
I will tried to test it.  Thanks!
Gustav Brock

Great! See you in an hour ...
urjudo

ASKER
@Gustav,
It works!  Thanks!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
urjudo

ASKER
Thank you so much Experts!!
Gustav Brock

You are welcome!