Results 1 to 5 of 5
  1. #1
    deepPowdah is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    2

    Opening ms access db from current using vba

    Is there any way to open another Access (MS Access 2007) from an open MS Access 2007 Database? In earlier versions, you use the shell command but I don't think this is an option in Access 2007. Is it possible in Access 2010?



    Thanks for your help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    What gave you the idea that Shell was no longer available? It is. You can also use FollowHyperlink.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    djoosten is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Wisconsin
    Posts
    7
    Why do you want to open the second database? Do you need to actually see the other open database or are you interested in just processing information from another database?

    I haven't tried it but I don't see why the Shell command would not work as long as the program to open argument is pointing to a the full path of Access and the database. Shell is a part of VBA so that should not have changed with versions.

    You might also want to take a look at the OpenDatabase method of DAO.

  4. #4
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Using the FollowHyperlink as Paul suggested, I've used the following which has worked very well:

    dim strFile as variant
    strFile = "C:\FolderName\SomeMdbFile.mdb"
    (or strFile = "C:\FolderName\SomeWordDoc.Doc")
    (or strFile = "C:\FolderName\SomeExcelFile.xls")
    Application.FollowHyperlink strFile

    (note: to open a folder itself....strFile = "C:\FolderName")

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I have used the following to open a second database (Acc2000/Acc2003)

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : testdb
    ' Author    : Jack
    ' Created   : 12/8/2009
    ' Purpose   : Test opening second A2003 database.
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Sub testdb()
    
    Dim dbsCurrent As DAO.Database
    Dim dbsSecond As DAO.Database
    Dim tbl As DAO.TableDef
       On Error GoTo testdb_Error
    
    Set dbsCurrent = CurrentDb
    Set dbsSecond = DBEngine.Workspaces(0).OpenDatabase("c:\users\jack\a2k\db1new.mdb")
    Debug.Print dbsCurrent.name
    Debug.Print dbsSecond.name
    
    For Each tbl In dbsSecond.TableDefs
    Debug.Print "  " & tbl.name
    Next
    Debug.Print Now()
    
       On Error GoTo 0
       Exit Sub
    
    testdb_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure testdb of Module Module5"
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Opening Access 2000 file in Access 2010
    By Jacob in forum Access
    Replies: 10
    Last Post: 02-12-2011, 06:56 AM
  2. Replies: 6
    Last Post: 11-18-2010, 04:00 AM
  3. Opening one report for current form???
    By GEPC in forum Reports
    Replies: 1
    Last Post: 07-15-2010, 10:46 AM
  4. Replies: 1
    Last Post: 07-14-2010, 01:34 PM
  5. Replies: 32
    Last Post: 09-16-2009, 10:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums