How to close an access application from another access application?

Posted on 2012-08-27
Last Modified: 2012-08-28
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!
Question by:SeyerIT
    LVL 119

    Accepted Solution

    try using the GetObject instead of createObject

    Dim oAccess As Object
    Set oAccess = GetObject(completePathToDB &"\Notify - Copy.accdb")
    LVL 77

    Expert Comment

    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.
    LVL 2

    Author Comment

    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.
    LVL 2

    Author Closing Comment

    That did the trick Capricorn!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now