Solved

Changing databases.

Posted on 1999-01-25
1
868 Views
Last Modified: 2008-03-17
I am trying to close one database and open another.

Why doesn't this work?

 Public Sub Vermilion()
 Application.CloseCurrentDatabase
 Application.NewCurrentDatabase "c:\acadiana\vermilion   parish directory.mdb"
 DoCmd.RunCommand acCmdOpenDatabase
 End Sub

The current dara base closes OK, but then nothing. BTW the path is correct.

Thanks.
0
Comment
Question by:instanet
1 Comment
 
LVL 2

Accepted Solution

by:
FlorisMK earned 50 total points
ID: 1615996
CloseCurrentDatabase is an Access method.
So I guess this Sub lives inside the current database.
After you close that database, the code is unloaded and subsequent lines are not executed.

You can't switch databases from within a database.

You can, however, open two databases at the same time from code.
So if you don't need to actually use the _interface_ on the second database, just open the second one using the OpenDatabase method. That will open Vermilion.mdb invisibly, but available to VBA manipulation of the data.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

776 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