Solved

vba code to close an access database

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

18 Experts available now in Live!

Get 1:1 Help Now