Started Access code by creating an application instance assigned to an object variable. At the end of the procedure, the variable went beyond the scope of access, so Access disconnected.
You accepted the answer to using a module level variable for an Access application instance. In this case, access remains enabled after the procedure is completed. However, if the user exits Excel, Access also closes.
If the goal is to start Access and stop it until the user decides to close it, just start Access directly without assigning the application instance an object variable ( Set db = New Access.Application ). This db variable would be useful if your Excel code needed it for other purposes. However, it is actually used only to open the db file.
You can use the Run WScript.Shell method to open the db file in an access session.
Private Sub bttnToAccess_Click() Const cstrDbFile As String = "C:\Users\wcarrico\Desktop\wcarrico-CapstoneFinalSubmission.accdb" Dim objShell As Object Set objShell = CreateObject("WScript.Shell") objShell.Run cstrDbFile Set objShell = Nothing End Sub
source share