Link to home
Start Free TrialLog in
Avatar of paulmcneil
paulmcneilFlag for United States of America

asked on

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
Avatar of Argenti
Argenti
Flag of France image

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.
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
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
Avatar of paulmcneil

ASKER

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

User generated image
Avatar of Norie
Norie

What was the problem with the database?
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan 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
Thanks!