Solved

vba code to close an access database

Posted on 2004-03-25
5
387 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 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Explanation of Access VBA code 2 35
Alter an update query which rounds 7 30
Create Form using Wizard 14 31
Restrict list data depending upon user name 3 20
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now