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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,
 
Upvote 0
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.
 
Upvote 0
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,
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

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