[AccessD] Open a database

Heenan, Lambert Lambert.Heenan at AIG.com
Wed Nov 15 09:58:09 CST 2006


What your code does is create an object (dbMyDB) to point to the external
mdb file. You would then be able to manipulate the tables, queries etc. in
that file via code.

It sounds like you want to actually start up the other database. For that
there are various ways. For example...

Sub OpenAnotherDb()

Dim strDBName As String
Dim dbl_D As Double
Dim strCommandLine As String

        strDBName = "C:\My Documents\ClientMasterUpdate.mdb"
        strCommandLine = Quote(SysCmd(acSysCmdAccessDir) & _
            "MSACCESS.EXE") & " " & Quote(strDBName )
        dbl_D = Shell(strCommandLine, vbNormalFocus)
        Application.Quit acQuitSaveNone ' closes the *current* database
End Sub

Function Quote(aString) As String
    Quote = """" & aString & """"
End Function

HTH

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gary J. Giever
Sent: Wednesday, November 15, 2006 10:41 AM
To: accessd at databaseadvisors.com
Subject: [AccessD] Open a database



This is frustrating.  All I want to do is open another database from the
currently open database.  The code is like the help examples:

Dim dbMyDB As Database
Dim strDBName As String
strDBName = "C:\My Documents\ClientMasterUpdate.mdb"
Set dbMyDB = DBEngine.Workspaces(0).OpenDatabase(strDBName)

But nothing happens.  What am I missing?


Gary J. Giever, M.A.
Applications Developer
ACCMHS

_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way  your home on the Web - http://www.myway.com


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list