Link to home
Start Free TrialLog in
Avatar of dobermannnn
dobermannnn

asked on

vba code to close an access database

Hi All,

Is it possible to write a piece of vba code to CLOSE an access 97 database from within ANOTHER access 97 database? If so, how?

Thanks in advance,
Nev.
Avatar of yatin79
yatin79

Try
DoCmd.Quit
if  you want to close the database.
"Try
DoCmd.Quit "
Yatin, he wants to close 1.mdb from 2.mdb

I'm sure jadedata knows some uber secret KEYS that will do this.
try

Dim oDB As Database

    Set oDB = Workspaces(0).OpenDatabase("c:\databases\1.mdb")
   oDB.Quit

Dave!
ASKER CERTIFIED SOLUTION
Avatar of dialdnet
dialdnet

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
Avatar of dobermannnn

ASKER

Hi dialdnet,

I have tried this but it closes 2.mdb.

i changed the module to code firstly to

    Dim db As database
    Set db = currentdb
    db.Close

which, when called from a button click did nothing

and then

   Dim db As database
    Set db = OpenDatabase("d:\tempdbs\db1.mdb")
    db.Close

the path specified being to the open db but this also did nothing. Any idea how to specify the db i want to close.

Many thanks (also to the others who have suggested things)
Nev.