Open Existing DB from another DB

AC5FF

Registered User.
Local time
Today, 08:50
Joined
Apr 6, 2004
Messages
552
I would have thought this was easy, but my tries have not been successful.

I want to be able to open a database with a button. I know that I could link tables/forms/etc between the two, but for security reasons I would rather have a button to open the seperate database.

I've tried searching here and Google, but came up blank. Maybe I'm just searching for the wrong thing. Anyone able to help???

Thx!
 
Nevermind...

I was using the "RunApp" command and pointing it to the MDB file.
I found a reference that said to RunApp won't open a file, but opens the EXE program.

With that bit of info I was able to get everthing to work as I was hoping. :D
 
Use the shell() function
Private sub open_Another_DB_Click()
Call Shell("C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE c:\MyFile.mdb", 1)
end sub
The first path is for the MSAccess.exe file and the second for the other DB
 
Here's a snippet of code where I open a number of other databases from my current database.

Code:
...Dim ThisDB As DAO.Database
Dim otherDB As DAO.Database
Dim strDbPath As String
Dim rs As Recordset
Dim rz As Recordset
Dim DBObjList As DAO.Recordset
Dim tbl As TableDef
   On Error Resume Next
 
Set ThisDB = CurrentDb
DoCmd.RunSQL ("Delete * from dbObjectsList;")

Set DBObjList = ThisDB.OpenRecordset("dbObjectsList")
Set rs = ThisDB.OpenRecordset("Select fullMDBCoord from A2Kmdbs")
Do While Not rs.EOF
    Debug.Print Now & " - Processing  " & rs!fullmdbcoord
    strDbPath = rs!fullmdbcoord
    Set otherDB = OpenDatabase(strDbPath)
    Set rz = otherDB.OpenRecordset(qsql)
   With DBObjList
    Do While Not rz.EOF
    
       .AddNew
       !name = rz!name......

I have access 2003.
 

Users who are viewing this thread

Back
Top Bottom