Scheduled task running twice

C

Chris

Hi,

My application has a number of things to do throughout the day. The first
task is to retrieve data at 6am and generate some reports. At 11:30am, get
different data and create a report; same for 2:30pm. All works well EXCEPT
my scheduled task runs twice! There is nothing in my code to rerun the app
and for the life of me I can't see anything wrong with the way I set up the
scheduled task.

My scheduled tasks open a form via a shortcut link to the form which then
runs the code and closes the app. I have 1 form for each different task.

Any suggestions?
 
S

Stefan Hoffmann

hi Chris,
At 11:30am, get
different data and create a report; same for 2:30pm. All works well EXCEPT
my scheduled task runs twice!
How did you verfiy this? Create a batch like this

@Echo Off
SetLocal

Set ACCESS = "fullPathTo\MSACCESS.EXE"
Set DATABASE = "fullPathTo\your.mdb"
Set LOGFILE = "C:\yourLogfile.txt"

Echo --- >> LOGFILE
Date >> LOGFILE

Start ACCESS DATABASE /cmd ScheduledTask

Date >> LOGFILE
Echo ... >> LOGFILE

EndLocal

and call it from your scheduled task.
My scheduled tasks open a form via a shortcut link to the form which then
runs the code and closes the app. I have 1 form for each different task.
First of all, I would change this and call an explicit method instead of
a form using an autoexec macro. Create a macro and name it AutoExec, it
will be executed automatically on each start (after the database is
opend). Call a Sub in this macro, e.g.

Public Sub StartUp()

If InStr(Command(), "ScheduledTask") > 0 Then
'execute logic for task.
End If

End Sub



mfG
--> stefan <--
 
M

meinJournal Produktion

hi Chris,

How did you verfiy this? Create a batch like this

@Echo Off
SetLocal

Set ACCESS = "fullPathTo\MSACCESS.EXE"
Set DATABASE = "fullPathTo\your.mdb"
Set LOGFILE = "C:\yourLogfile.txt"

Echo --- >> LOGFILE
Date >> LOGFILE

Start ACCESS DATABASE /cmd ScheduledTask

Date >> LOGFILE
Echo ... >> LOGFILE

EndLocal

and call it from your scheduled task.

First of all, I would change this and call an explicit method instead of
a form using an autoexec macro. Create a macro and name it AutoExec, it
will be executed automatically on each start (after the database is
opend). Call a Sub in this macro, e.g.

Public Sub StartUp()

If InStr(Command(), "ScheduledTask") > 0 Then
'execute logic for task.
End If

End Sub



mfG
--> stefan <--
 
C

Chris

First off thanks for the suggestions. I've got a couple of questions in the
body of your reply below:



Stefan Hoffmann said:
hi Chris,

How did you verfiy this?


I get 2 emails where I should have 1.



Create a batch like this
@Echo Off
SetLocal

Set ACCESS = "fullPathTo\MSACCESS.EXE"
Set DATABASE = "fullPathTo\your.mdb"
Set LOGFILE = "C:\yourLogfile.txt"

Echo --- >> LOGFILE
Date >> LOGFILE

Start ACCESS DATABASE /cmd ScheduledTask

Date >> LOGFILE
Echo ... >> LOGFILE

EndLocal


I'm a rookie here. Can I just copy your code and toss it into notepad and
save it as a .bat? Does the " Start ACCESS DATABASE /cmd ScheduledTask" line
open my database and run the procedure called "ScheduledTask"?


and call it from your scheduled task.
First of all, I would change this and call an explicit method instead of
a form using an autoexec macro. Create a macro and name it AutoExec, it
will be executed automatically on each start (after the database is
opend). Call a Sub in this macro, e.g.

Public Sub StartUp()

If InStr(Command(), "ScheduledTask") > 0 Then
'execute logic for task.
End If

End Sub



mfG
--> stefan <--

I think I understand what you're doing here - I guess the question is just
regarding the batch file.
 
S

Stefan Hoffmann

hi Chris,
I'm a rookie here. Can I just copy your code and toss it into notepad and
save it as a .bat?
It should run.
Does the " Start ACCESS DATABASE /cmd ScheduledTask" line
open my database and run the procedure called "ScheduledTask"?
Nope. The values after /cmd can be read using to Command() function. You
use it in the sub called by the autoexec macro to determine whether
you're running the .mdb from the batch/task or by simply opening it.

mfG
--> stefan <--
 

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