Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vba code to close an access database

Posted on 2004-03-25
5
Medium Priority
?
408 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
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 160 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

927 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