=========
QUESTION
———
I have a database that I use on a regular basis, and when I am finished working with that database, I invariably always move on to the same second database file.

Is there a way for me to open another file using a button or sub within VBA?

 

=========
ANSWER
———
See the code in EXAMPLES

 

=========
EXAMPLES
——— 
Shell "C:Program FilesMicrosoft OfficeOffice14msaccess.exe S:mauricessharestore_listingUpdateStoreListings.accdb", vbMaximizedFocus

——— 
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String

strDbName = "S:mauricessharestore_listingUpdateStoreListings.accdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False)
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing

*Note: this second bit of code opens the new database file in seemingly the same instance, if you will, of MSAccess, causing this file to close at the same time as you close the database that houses this code to open it.
Because of this, we prefer the first example using Shell…

 

=========
APPLIES TO / KEY WORDS
———
Microsoft Access
Open File
VBA

 

=========
REF
———
http://www.erlandsendata.no/english/index.php?d=envbafoldersfileopen 
http://social.technet.microsoft.com/Forums/en-US/officeitpro/thread/9f218121-0cbe-413a-82e0-9a87ebef4d88

  


http://www.anysitesupport.com/access-vba-open-a-database-or-file-using-vba/ 
http://anySiteHosting.com