Close Access, or Timer/Timer Event Help

W

Wendy

Hi,

I would like to be able to close Access, after a macro procedure runs in the
middle of the night - close at 3am.

By searching on this site, I have found coding that will:
* Application.quit if you click a text box

I also found another method that indicated a set time to close down, but got
very confused as to how to set it up, as the database does NOT currently have
a form (used only for website backend)., and the notes seemed to indicate
that this was essential?

By playing around, I also found that I could add the 'Exit' command to the
AutoExec macro, but this ended up being a mistake - while it functioned
exactly as required, I then can't get back into the database to remove it or
make changes, either!

Is there no simple little .exe file around that will do this simple task,
that I can set up to a Windows Scheduled Task?

Otherwise, please help with further instructions as to setting up the Timer
sequence, I am so confuseddd......

This is what I have - copied from another posting:

Private Sub Form_Time()
If Now() > TimeValue("03:00") Then
Application.Quit
End If
End Sub

I can type this into the Module area and save it, but am not sure how to
start the timer event to check the time. Or how to do what I am trying to
achieve here?

I can create a simple form, and open it via the AutoExec macro after other
stuff is done, so a timer event can be linked to a form that is then open,
but is this the correct way to go on this?

Please help, very confused on this one last bit of coding to make everything
work as it needs to.

TIA
 
J

John Spencer

If you are using an auto-exec macro you can probably get back into the
database design mode by holding down the shift-key when you open the
database. Unless you have disabled the bypass key, holding down the shift
key will allow you to bypass the auto-exec macro.

So your method of adding Exit to your macro would probably work.


Alternative would be to use the form. You need to set the form's Timer
Interval to something other than zero. I would suggest 60000 (60 seconds)
and then in the form's Timer Event (On Timer ) using the following code. I
suggest the 60 seconds on the guess that you might open the form at the
beginning of the process. If you open the form at the end of the event then
you could set the Timer Interval to 1

Private Sub Form_Timer()
If Time() > #03:00# Then
Application.Quit
End If
End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
W

Wendy

Thank you, John.

I will go with the simple and elegant solution of using the SHIFT key when
opening the database, I like the KISS method, when I can use it! :)

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top