By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

Detecting Windows Shutdown in Access 97

P: n/a
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:

Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.

-Tom.

Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Nov 12 '05 #2

P: n/a
In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of the
application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close
down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if
there is no user intervention.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #3

P: n/a
You would have to subclass the app and watch for the appropriate system
shut down Message. I've seen such code over in VB land which would work
with Access directly. A google search should yield several solutions.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Les Desser" <le****@[127.0.0.1]> wrote in message
news:Kz**************@dessergroup.com...
In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm ifthey want to shut the application. If the user is not at his desk andpower fails and the UPS instructs Windows to close, then Windows willnot shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.
Not easily.
The next best thing is to detect that your app is closing. You do thisby opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of

the application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if there is no user intervention.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))


Nov 12 '05 #4

P: n/a
On Sat, 4 Oct 2003 21:37:12 +0100, Les Desser <le****@[127.0.0.1]>
wrote:

Steven is right. When I commented "not easily" I meant you'll need a
DLL that hooks the message queue and checks for shutdown messages.
These should be available online. A few years back the company now
called Infragistics had one - they called it something like a message
spy.

-Tom.

In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of the
application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close
down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if
there is no user intervention.


Nov 12 '05 #5

P: n/a
In article <jb********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
Steven is right. When I commented "not easily" I meant you'll need a
DLL that hooks the message queue and checks for shutdown messages.
These should be available online. A few years back the company now
called Infragistics had one - they called it something like a message
spy.


Thanks to you both - I will investigate
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #6

P: n/a

<snip>

Thanks to you both - I will investigate
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))


I could do with something similar - if you find the info please share it
with the group. I will do the same.

Nick
Nov 12 '05 #7

P: n/a
One way is to use Visual Basic to detect the shutdown and perhaps
update a record in a table when it detects it. Your Access program
could keep checking for the record in the table (eg via a timer)

VB has a query unload event that can tell what causes the unload.

For an example of this, goto:

http://www.aylott.com.au/software.htm

and download the Windows Utilities (WINUTILS). Look for QRYEXIT in the
help file. This simply displays a dialog when it detects a Windows
shutdown but could be enhanced, of course...

Les Desser <le****@[127.0.0.1]> wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.

,-._|\ David Aylott (Author of Access Version Checking utility)
/ Oz \ ng***@bigfoot.com (Melbourne, Australia)
\_,--.x/ Shareware, FAQ, hints & tips at:
v http://www.aylott.com.au/
Nov 12 '05 #8

P: n/a
In article <vo************@corp.supernews.com>, Nick Marshall
<Nick@Marshall.?.COM.invalid> writes

I could do with something similar - if you find the info please share it
with the group. I will do the same.

I have done some hunting in Google and MS KB without any luck.

I'm not sure of your need, but what I have done will suffice for me at
the moment.

I have changed my "Do you really want to close down this application"
question in the Unload event from a Msgbox to loading a form in Dialog
mode. This form has a Timer Interval of 5 seconds and gives the user
the option to cancel.

After the five seconds, the form closes and the calling form can detect,
via a Global variable, whether a user cancel was requested or not. If
not it allows the unload to continue.
==========
An other method I just thought of, based on a suggestion by Tom van
Stiphout and his comment that forms are closed in the reverse order of
their being opened (I presume that is what he meant with:- the first
hidden form will be last to close).:-

1. Open the master menu

2. Open a hidden form.

3. If the master menu detects a closedown it checks if the hidden form
is still open. If it is then the user has requested a closedown on the
master menu. If it is not then it is a system initiated closedown.

I have two problems though. First, if a user closes the application not
via the master menu but via the Widowns close (X) it will look like a
system closedown. The second is that when I run a test by doing a
log-off with several windows open in my application, it is the master
menu (opened first) that detects the closedown while the other windows
stay open.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.