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?
See the code in 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)
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