how to make an ms access database like a main menu to open other access databases

hi

how can i make an access database form like a main menu to open other database with vba.


thanks
bill201Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can open another instance of Access, with another database, like this:

Sub OpenAnotherDatabase(DatabasePath As String)
  Dim path As String
  path = SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE " & DatabasePath

  Shell path
End Sub

If you want to open a different database in the current instance of Access:

Application.OpenCurrentDatabase YourDatabasePath
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bill201Author Commented:
thanks for this code it's open access but it's not open any database
0
mbizupCommented:
No points wanted -

If you supply a valid DatabasePath when calling the Sub that Scott posted, it most certainly WILL open the database (but it might appear minimized in the tray at the bottom of your screen).

Call the sub like this:

Call OpenAnotherDatabase("C:\MyTestDB.accdb")   ' replace with your own valid db path

Open in new window


To make it more obvious, you can maximize and set focus to the database you are opening by changing the Shell line in Scott's code to this:

 Shell path, vbMaximizedFocus

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rey Obrero (Capricorn1)Commented:
test this code

dim accObj As Object, dbName As String

dbName = "<path to your db\yourdb.accdb">
set accObj = createobject("access.application")
    accObj.OpenCurrentDatabase dbName
    accObj.UserControl = True  ' < this is important
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
it's open access but it's not open any database
Make sure the DatabasePath variableis the fully qualified path to the database. You cannot just pass in a name, for example - you must pass in something like "C:\MyFolder\MyDatabase.accdb"
0
bill201Author Commented:
thanks a lot scott and  mbizup and rey, thanks to you the issue has been solved.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.