Automatic shutdown of the application

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hi everyone!

I have an application made with Access XP and I want it to close automaticly
à midnight 12:00am).

What I need is a way to put a realtime clock in my application... Is it
possible?

Thanks

JS
 
You will need a form running, hidden is ok. Use the timer event of the form
to check the current time. Set the timer interval for 1000 for once a second
or longer if desired. If the time is after midnight but before a later time,
say five minutes after midnight, then DoCmd.Quit or Application.Quit. You
will need to decide how you want to handle unsaved database objects. Also,
whether or not you want to abort any pending record updates in open forms.
If so, loop through the open forms and if they are dirty, issue an Undo on
the form.
 
Open the form in design view. Open the Properties sheet for the form. On the
Events tab you will see two options, On Timer and Timer Interval. The Timer
Interval controls how often the On Timer event runs. The value for Timer
Interval is in milliseconds, so 1000 is 1 second. In the On Timer event,
place the code that you want to run to check the current time. Use an If
statement to determine it the current time is within the time parameters you
have decided on and it so, quit the application.

Example:
If Time >= #12:00 AM# And Time <= #1:00 AM# Then
Application.Quit
End If

The # signs are date/time delimiters, similar to using " marks for strings.
 
Back
Top