Share via

Open one database from another

Anonymous
2010-10-15T14:12:47+00:00

I have a 2007 db and want to add a button to a form to open another database.  I tried using a macro and using the runapp command, but only got it to open Access, not the actual database.  So I went to code and have the following:

Private Sub Command27_Click()

OpenDatabase "c:\Documents and Settings\Operations\Desktop\archived controlled docs.accdb"

End Sub

When I click on the command button in the form, nothing happens.  Nothing opens, no error, nothing.  I was sure this used to be fairly easy and don't know what I'm missing here.  Any ideas?  Thanks!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-10-15T14:58:26+00:00

Hi

You normally need to open the programme (access) 1st then the (application) database - like this

Private Sub Command27_Click()

Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE""   ""c:\Documents and Settings\Operations\Desktop\archived controlled docs.accdb", 1)

DoCmd.Quit  ' this will close your orginal DB - you can delete it if you don't need it '

End Sub

If you don't know the path - you can cheat ;-)

To get the 1st bit of the code some thing like "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"

It may be different on your machine

in Acc 2007 it is sometimes here

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office

Click Run

Navigate to your access programme and then click Run - then just copy the path from the run box (big cheat I know ;-)

To get the path the database

Click Run - browse

Select all file types (in the file type dropdown)

Navigate to your DB

Note - the number of commas that I have used in the code above and make sure you do the same. Also note there is a space between the 2 sections of the path

Good luck

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-10-15T15:30:36+00:00

    AWESOME!  Thank you so much - worked like a charm!!

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2010-10-15T15:18:15+00:00

    Another option is to use Application.FollowHyperlink filepath


    Hope this helps, Scott<> P.S. Please post a response to let us know whether our answer helped or not. Microsoft Access MVP 2009 Author: Microsoft Office Access 2007 VBA Technical Editor for: Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports and Queries

    Was this answer helpful?

    0 comments No comments