Avatar of bfuchs
bfuchs
Flag for United States of America asked on

Getting notification upon code pausing execution.

Hi Experts,
I have some (Access) code that is supposed to be running all the time.
Would like to get an email notification in case the code stops executing for whatever reason.
What is the best way to accomplish that?
Thanks
VB ScriptMicrosoft AccessVBA

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Martin Liss

If it's because of an error then you could add an error routine or routines that display a msgbox and/or sends you an email when the error happens. If it's not then without some external program checking some value produced by the Access program I don't how how you'd do it.
bfuchs

ASKER
Hi,
If it's not then without some external program checking some value produced by the Access program...
Perhaps upon starting the Access code we can get the handle of the Access program, then have a batch file start looking for that handle id and if doesn't find it, send an email...
Does that make sense?
Thanks,
Ben
Daniel Pineault

Stops running how?  An error?  The user stops it?  Something else?

If you mean an error, then add an error handler that included an email routine (SendObject is the simplest way to do this).
If you mean the user stops it, then the question becomes how do they stop it?  Close, cancel button, ... you'd need to trap the button click, form closure, ... and use a similar email routine as previously mentioned.
If it's stopped by the db being closed, then open a hidden form at the startup, and use that's form's close event to send an email.  Thus when the db is closed, it will first close the hidden form triggering the email.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Martin Liss

Perhaps upon starting the Access code we can get the handle of the Access program, then have a batch file start looking for that handle id and if doesn't find it, send an email...
Does that make sense?
Yes.
bfuchs

ASKER
Stops running how?  An error?  The user stops it?  Something else?
This will be placed on the server and keep running indefinitely, no user intervention.

What I'm looking to oversee is

 A) If got stuck by an unhandled error event.
 B) System crash.
 C) Server restart w/o restarting the program.
 D) Hardware failure etc...

Any idea how to put it to work the idea mentioned above?

Thanks,
Ben
Gustav Brock

If the code stops executing, it stops, thus cannot do anything like sending an e-mail.

So, you will have to generate some kind of heartbeat with a certain interval, then watch if this stops.
You could:
  • send an e-mail as the heartbeat; if the e-mails stop arriving, the application has stopped.
  • create a log file and have another application to watch this; if no new entry is created, an e-mail will be sent to you
  • create a syslog entry if you have a syslog server running

What to choose depends very much on your scenario.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
bfuchs

ASKER
Thanks to all participants!

@Jim,
I was thinking (this morning) about similar approach.
To have a file on the server and every time the code runs modify that file, then later have a program examining the time of that file last updated...

Thanks,
Ben
Daniel Pineault

Jim, but what guarantees the 2nd db is running?
bfuchs

ASKER
@Daniel,
Once I have this split into two applications, and they can be running in separate servers, it should be solving most of my concerns, as very unlikely both servers are down at the same time.
Thanks,
Ben
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Daniel Pineault

Valid point.
Jim Dettman (EE MVE)

Apologies to all....I am not getting any notifications on my questions.

@Daniel,

<<Jim, but what guarantees the 2nd db is running?>>

 The first.  They check each other.

@Ben,
<<Once I have this split into two applications, and they can be running in separate servers, it should be solving most of my concerns, as very unlikely both servers are down at the same time.>>

 Exactly.   You'd want them running on separate servers to cover all the bases.  But in the example above, these happen to be running on the same server.  It would have been better had they not been though.

 Even so, it's rare for a server to be down (lots of other things get noticed) and it's never been an issue.   This setup has been running for over fifteen years and I'm sorry to say, the server has never been the problem<g>.

Jim.