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")

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

Any thoughts?

Thanks in advance!
Jarred MeyerProduction ManagerAsked:
Who is Participating?
Rey Obrero (Capricorn1)Commented:
try using the GetObject instead of createObject

Dim oAccess As Object
Set oAccess = GetObject(completePathToDB &"\Notify - Copy.accdb")
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..

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.
Jarred MeyerProduction ManagerAuthor Commented:
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.
Jarred MeyerProduction ManagerAuthor Commented:
That did the trick Capricorn!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.