Reputation: 48
I created a launch app for the database users to open the front end of a particular database. For example, the users open the launch app (which is an Access DB on a shared network), which then performs the following actions:
This process makes it much easier for me to implement updates to the front end and works great for almost everyone. However, there are a couple users that are experiencing the same issue. When they open the launch app, the front end is copied to their local drive and opened but when the "Application.Quit" line is called, both the launch app AND the front end close.
Does anyone have any idea what might be causing this and why it would only affect some users and not others? Below is a sample of the code in the launch app that opens the local db (after it has been copied from the network location) and then closes itself (and is supposed to leave the front end open).
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\Databases\Database1.accdb"
appAccess.Visible = True
appAccess.RunCommand acCmdAppMaximize
Set appAccess = Nothing
Application.Quit
Thanks!
Tim
Upvotes: 1
Views: 1767
Reputation: 32642
The problem is: the newly opened application is just a variable, and like any variable, it gets destroyed once it goes out of scope.
To avoid this from happening, set .UserControl
to True, to indicate the user is controlling the application and responsible for closing it.
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\Databases\Database1.accdb"
appAccess.Visible = True
appAccess.UserControl = True
appAccess.RunCommand acCmdAppMaximize
Set appAccess = Nothing
Application.Quit
Upvotes: 4