Solved

vba code to close an access database

Posted on 2004-03-25
5
394 Views
Last Modified: 2008-02-26
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.
0
Comment
Question by:dobermannnn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:yatin79
ID: 10681471
Try
DoCmd.Quit
if  you want to close the database.
0
 
LVL 11

Expert Comment

by:phileoca
ID: 10681536
"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.
0
 
LVL 34

Expert Comment

by:flavo
ID: 10681674
try

Dim oDB As Database

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

Dave!
0
 

Accepted Solution

by:
dialdnet earned 40 total points
ID: 10683156
By what process are 1.mdb and 2.mdb opened?

You could do the following if you want to close 1.mdb from 2.mdb


In 1.mdb create a module with the following code

public sub CloseMyDB()
   docmd.quit
end sub

Inside of 2.mdb when you are in code view, go to tools, references on the menu. Add 1.mdb
Now you can call CloseMyDB from anywhere in 2.mdb

Let me know if this works, I am pulling this from memory as I do not have Access on this pc.

Good Luck!
0
 

Author Comment

by:dobermannnn
ID: 10686161
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.


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question