Only allow one instance of a database to be open

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

Hope some one can help. We have a access database FE/BE some of the people
have the same front end open 2 or 3 times on the same computer. Is there
any way to have access check to see if the database is already open and if
so abort the opening of it a second time and perhaps a message box to inform
the user that the database is already open.

Thanks, in advance.
 
Store a value in the Windows registry by running code along these lines when
the front end application is started, e.g. in the open event of the
application's opening form:

If GetSetting(Appname:="MyApp", Section:="Startup", _
Key:="InUse", Default:="False") = "True" Then
MsgBox "Application Already Open", vbExclamation, "Invalid Operation"
DoCmd.Quit
Else
SaveSetting "MyApp", "Startup", "InUse", "True"
End If

Setting the default argument of the GetSetting function to "False" is
necessary as the key won't exist the first this code executes.

When the application is closed, e.g. in the Close event procedure of a form
which is open all the time, reset the setting:

SaveSetting "MyApp", "Startup", "InUse", "False"

If you don't have one form, such as a switchboard, which remains open all
the time then use a hidden form as the application's opening form, keep it
open but invisible and open the usual opening form from this one's open event
by amending the code, e.g.

Else
SaveSetting "MyApp", "Startup", "InUse", "True"
DoCmd.OpenForm "frmSwitchboard"
 
Back
Top