Close an invisible intance of MS Access

I opened an instance of an Access 2003 mdb in VBA 2010 using:

set appacc = CreateObject("Access.Application"

With appacc
     Opencurrentdatabase strPathFile
end with

I had an error in the opened database and had to use Task Manager to close it.
The ldb file is still listed in explorer and when I try to delete the ldb, I'm told the database is open. So I have, in effect an invisible instance of Access running.

What is the VBA code to close this invisible instance of Access?
Thanks
paulmcneilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ArgentiCommented:
There is no VB code to close an "invisible instance of access".
Your invisible instance is there because your program has exited and lost the address to the instance you created when opening your database in your code.

First of all open your Task Manager and manually kill your MsAccess instance(s) so you can unlock your current situation and be able to delete the lock file (.ldb)

Then change your VB code using On Error Goto statement, so that in case of an exception, you should be able to close the Ms Access instance before finishing your program.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Try something like this:

Dim appacc As Application
Set appacc = CreateObject("Access.Application")

With appacc
        .OpenCurrentDatabase "strPathFile"
       
        ' other code
        .CloseCurrentDatabase
       
End With
Set appacc = Nothing
0
paulmcneilAuthor Commented:
Argenti,
My "invisible" instance of Access does not appear on the Task List.

DatabaseMX,
I tried that and it did not work. It just opens a second instance
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ArgentiCommented:
Paul,
If you cannot delete the lock file (.ldb) then it's because something has your database opened. That something is the "invisible" instance of Access you are talking about.
Please make sure you check option "Show processes from all users" in your Task Manager.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Well ... what I posted was not to Close the 'hidden'  instance, but instead possibly how to avoid the next time.

I suggest you reboot your system. If you are not seeing MSACCESS.EXE in the Processes List of Task Manager, something is very wrong ....

tm
0
NorieData ProcessorCommented:
What was the problem with the database?
0
mbizupCommented:
Give this a try -- similar to mx's code, but it uses GETobject (instead of create) to retrieve and quit other instances of Access:

Sub CloseOtherAccessInstances()
    Dim acc As Access.Application

    Do Until Err.Number <> 0
        Set acc = GetObject(, "Access.Application")
        If acc.Application.CurrentDb.Name <> CurrentDb.Name Then acc.Quit

   Loop
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paulmcneilAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.