adriany
If you do not want to kill your app after some amount of inactivity, but
need to make sure it is not running between the hours of say, midnight and
1:00AM here is what you need to do.
1) Create a form that is ALWAYS open while your application is running.
This form can be hidden if need be, or could be a menu that you have built.
2) Set the timer interval for the form to some reasonable value. I like
to use 600000, which will fire off any code in the Form_Timer event every
ten minutes.
3) In the Form_Timer event you need some code that compares the current
time to the times you have set to kill the app. Something like this would
work.
If Time > CDate("12:00:00 am") And Time < CDate("01:00:00
am") Then
DoCmd.Quit
End If
The big weakness in this solution is that if your users computers clocks are
way off than the app could kill itself at exactly the wrong moment, Like in
the middle of a presentation to a prospective customer.
Frankly I like Albert's solution as it does not rely on the accuracy of the
computers clock.
Ron W