run macro from shedule task???

CJBIRKIN

Drink!
Local time
Today, 19:59
Joined
May 10, 2002
Messages
256
Hello
I am trying to set up an automatic e-mail from access using the windows task sheduler. The scheduler opens the database and i get the e-mail sent using a macro but only if its run from the autoexec macro i.e the e-mail macro is launched when the database is opened.

The problem is that i want to be able to close the db down automatically. I can't do this from the autoexec macro for obvious reasons.

Is there a command i can use in the schedule command line to run a particular macro within the database?


M:\Information\procedures\OURLOG.mdb ...?/E-MAIL_REPORT

Cheers
Chris
 
Why don't you just open a form (Just make it very tiny) that opens after the email (Put it in the AutoExec macro after your email line). Uses its timer event and use "QUIT" on the Timer Event. You can give the form 1000 Milisecond (1 Second) of time to be open.
 
Hello
if i understand your answer correctly then the series of events is:

1: db is opened
2: autoexec runs form
3: form load pings of e-mail
4: form closes

however the db is not always being used so i want the db to close after the e-mail is sent. i.e the whole process is in the background. If the process is linked in anyway to the autoexec macro the events will occur everytime the database is opened. Apart from only needing the report once a day i cannot kill the db from a process linked to the autoexec as it would do this everytime it's opened.

does this make sense??

Chris
 
Then,

Make the Shutdown form a Fixed Dialog form (basically a custom message box) Have the autoexec macro open this form after the email.


Give the forms timer 10000 miliseconds (or 10 Seconds). Have a label on the form say:

Do You Want To Cancel Autoshutdown?

Add one button with a caption of "YES"

On the Click event of this button add this code:

Me.Close

=============================================
This will give the user 10 seconds to by-pass the auto shutdown. Otherwise the Timer Event will run and the QUIT command will be processed.
 
For what it's worth, here's how I've done this:

Create a dummy form. For the Open event, insert the code that will make everything happen. At the very end of the event, put the command:

Application.Quit
(This is using VBA; I'm sure there's an equivalent for macros.)

That exits the database completely. Then from the Tools->Startup menu, have it display the dummy form you just created. When the db is run, it automatically opens the form, which closes the db.

Of course, this requires you to have a whole, separate db devoted to this one form. I don't know if that works for you, but I thought I'd throw it out there!
 

Users who are viewing this thread

Back
Top Bottom