Close on Access Database from Another Access Database (1 Viewer)

JReagan

Registered User.
Local time
Yesterday, 23:30
Joined
Oct 13, 2009
Messages
32
I want to be able to close one access database by using another. I did have some code that involved the "GetObject("FilePathName") command, and it worked but of course I didn't save it and I managed to lose it :(
What I'm looking for is a code that when I have it attached to a button on a form it will close another (specific) database that is currently open at the same time and not error out if the database to be closed is for some reason not open. Any ideas?

JB
 

JReagan

Registered User.
Local time
Yesterday, 23:30
Joined
Oct 13, 2009
Messages
32
Code that I have the works for this close is:

*****Code Start*****
Dim ObjAccess As Access.Application
Set ObjAccess = GetObject(""File Path Name")
ObjAccess.CloseCurrentDatabase
ObjAccess.Quit
*****Code End*****

My problem is that if I accidently hit this button when the other database isn't open, it get an error, is there a way to add this to an "If" statement?

JB
 

Users who are viewing this thread

Top Bottom