automatic shut down

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking for a way to close my application at 11 pm daily if the user
forgets to close the application and leaves it running.
 
The main problem is to determine what you want to do with any incomplete
edits. For example, the user had edited 3 of 4 textboxes on a record when it
was time to go home, so they left it expecting to pick up where they left
off. You will need to advise the users that this is unacceptable (it should
be anyway, what if the computer crashed over night for some reason).

To do this, you need a form that is open anytime your application is open. A
hidden form just for this is fine if you don't have a form that stays open.
Place the code in the Timer event of the form and set the form's Timer
Interval to 60000 (1 minute). Check the time of day using a If statement and
if it is 11pm then close the application. Be aware that you probably won't
catch it at exactly 11pm, so you'll need to check for a time range, perhaps
#11:00 PM#. This would give you a one hour interval in which to shut down
the application.

As part of your shutdown process, you'll need to go through all open form
(excluding the one running this code) and if they are dirty, issue an Undo
then use the command

Application.Quit acQuitSaveNone

The acQuitSaveNone will abort any structural changes, not record changes.
 
Thanks Wayne, your solution should do the trick.

Wayne Morgan said:
The main problem is to determine what you want to do with any incomplete
edits. For example, the user had edited 3 of 4 textboxes on a record when it
was time to go home, so they left it expecting to pick up where they left
off. You will need to advise the users that this is unacceptable (it should
be anyway, what if the computer crashed over night for some reason).

To do this, you need a form that is open anytime your application is open. A
hidden form just for this is fine if you don't have a form that stays open.
Place the code in the Timer event of the form and set the form's Timer
Interval to 60000 (1 minute). Check the time of day using a If statement and
if it is 11pm then close the application. Be aware that you probably won't
catch it at exactly 11pm, so you'll need to check for a time range, perhaps
the application.

As part of your shutdown process, you'll need to go through all open form
(excluding the one running this code) and if they are dirty, issue an Undo
then use the command

Application.Quit acQuitSaveNone

The acQuitSaveNone will abort any structural changes, not record changes.
 
Back
Top