Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

How to close an access application from another access application?

Any idea how I could code shutting down another access application from a different access application?

I found some code that looks like this:
           
Dim oAccess As Object
Set oAccess = CreateObject("Notify - Copy.accdb")
oAccess.Quit


When I run this though it sets oAccess = Nothing when it hits that second line.

Any thoughts?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As far as I know, if you didn't open the database through automation, then you won't be able to close it .

To force a close programmatically, the app to be closed has to be looking for a 'message' to tell it to close. It does that through a form running a timer that checks for the presence or absence of a known file.
If the file is present, the timer procedure closes the app.

See here for an example..
http://support.microsoft.com/kb/304408

Other than that, then closing an application is a O/S level action and requires Windows APIs to do it.
There is some code here, although I 've never tried to used this method on an Access app.
http://access.mvps.org/access/api/api0025.htm
Avatar of Jeremy Campbell

ASKER

Thanks Guys,

Capricorn thanks for that, I'll give that a try.

Peter, I'm actually doing something very similar to what you are mentioning. I actually have a hidden accessdb running in the backround at all times that acts as a messaging service as well as a method of controlling the other applications they may be running.

So whenever I send the notify form a message it checks to see if it is a shutdown command and then will follow the code, which is where I want to try and tell it to close a specific application (another Access db) on there computer.

I actually already put some code into the Other access applications that is also looking at the notifications table to see if there is a launch message sent so that the other applications can restart the hidden notify form if need be. So I guess in theory it could check to also see if it is a shutdown command and if so then just close itself.
That did the trick Capricorn!

Thanks