Open Access 2007 database from another

HCB

New member
Local time
Today, 18:33
Joined
Jul 17, 2009
Messages
7
We have just converted from Access 2003 to Office (Access) 2007 and I am trying to convert a script we had to ADO structure. The intent of the script is to move via form button from one databast to another.

Below is the script from "Before" and "After". The intent of the test is to move from OpenDatabase_1 to and from OpenDatabase_2 and back.

The "After" does not yield an error, but does not do anything. Any suggestions are appreciated.

Before (Access 2003)
Private Sub QuitandReturntoMaster_Click()
On Error GoTo Err_QuitandReturntoMaster_Click
' Create instance of Access Application.
Set appAccess = CreateObject("Access.Application")
'Open BP_Control Database
appAccess.OpenCurrentDatabase "\\vhapthshare\datawarehouse\PrimaryCare\CGPI\CGPI.mdb", False
DoCmd.Quit
Exit_QuitandReturntoMaster_Click:
Exit Sub
Err_QuitandReturntoMaster_Click:
MsgBox Err.Description
Resume Exit_QuitandReturntoMaster_Click
End Sub


After (Access 2007)
Private Sub Command0_Click()
'Declare openMaster as connection
Dim openMaster As ADODB.Connection
'Define connection object
Set openMaster = New ADODB.Connection
'Specify data provider
openMaster.Provider = "Microsoft.ACE.OLEDB.12.0"
'Open Master database
openMaster.Open "\\vhapthshare\datawarehouse\hb\OpenDatabase2_Test.accdb"
End Sub

Thanks in advance.
 
Welcome to AWF! :)

Does the "Before" code work in 2007 with an accdb/accde?

Curious, why do you want to switch to ADO in 2007?
 
No. When trying to run the 2003 code in 2007 The quit command works (i.e. the database closes), but it does not open the master. After some research it appears that 2007 does not recognize DAO commands.

That is the reason trying to do in ADO.

Thanks.
 
That is interesting since Access 2007 went back to using DAO as the default not ADO.

To open a second database, I have always used this:

Start an app with ShellExecute

After you paste the code for the ShelExec in a module, your code would then be:

Code:
Private Sub QuitandReturntoMaster_Click()
On Error GoTo Err_QuitandReturntoMaster_Click

HandleFile("\\vhapthshare\datawarehouse\PrimaryCare\CGPI\CGPI .mdb", Win_NORMAL)

DoCmd.Quit

Exit_QuitandReturntoMaster_Click:
Exit Sub
Err_QuitandReturntoMaster_Click:
MsgBox Err.Description
Resume Exit_QuitandReturntoMaster_Click
End Sub
 
I've noticed that the original code posted in post #1 has no DAO in it. So, what makes you think this is a DAO problem?
 

Users who are viewing this thread

Back
Top Bottom