paulmcneil
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.Appli cation"
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
set appacc = CreateObject("Access.Appli
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
Try something like this:
Dim appacc As Application
Set appacc = CreateObject("Access.Appli cation")
With appacc
.OpenCurrentDatabase "strPathFile"
' other code
.CloseCurrentDatabase
End With
Set appacc = Nothing
Dim appacc As Application
Set appacc = CreateObject("Access.Appli
With appacc
.OpenCurrentDatabase "strPathFile"
' other code
.CloseCurrentDatabase
End With
Set appacc = Nothing
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
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.
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.
What was the problem with the database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
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.