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


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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

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
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

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

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
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"
bill201Author Commented:
thanks a lot scott and  mbizup and rey, thanks to you the issue has been solved.
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.