Open Database Macro?

mr_connell

New Member
Joined
May 15, 2006
Messages
18
Can you create a macro in one database to open a totally different database?
If so...HOW?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
Yes you can. Here is the actual statement from one of my Access databases where I start another database.
Code:
      RetVal = Shell("""" & SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE""  " & _
                "g:\apps\JobRecords\RefreshDB.mdb" & " /cmd """ & CurrentDb().Name & _
                """", vbNormalFocus)
And it is followed by this statement:
Code:
    Application.Quit
Retval is a global variable I use for VERY temporary things. In this case it is never used, except as the receipent of the Shell function's return.
This is then followed by the application quit, so the Refresh database can copy the network MASTER back to the local C: drive. (the Refresh database then recalls the original DB name)

Last note: The path to the RefreshDB.mdb should be in a Const variable defined in my Declarations area. And yes, I do plan on fixing it.
HTH,
 

mr_connell

New Member
Joined
May 15, 2006
Messages
18
Where do i type this information?
And where do i insert my database names and locations into the equation?
Thank you very much for your help.
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
This information goes where ever you want to put it. Best to put it within the OnClick event of a button you create to open another database.

If you would look at the "equation" you would see something that has .mdb following it. A Microsoft Access database is known by the suffix of .mdb. Of course, the stuff in front of the database name is the path (location) of the database.

HTH,
 

mr_connell

New Member
Joined
May 15, 2006
Messages
18
Microsoft Visual Basic error keeps comming up "Compile error: Variable not defined" and it is highlighting the "RetVal ="
What can i do to fix this?
 

Watch MrExcel Video

Forum statistics

Threads
1,130,342
Messages
5,641,592
Members
417,224
Latest member
llama9207

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top