Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent Multiple DB Instances

Status
Not open for further replies.

krymat

Technical User
Jul 25, 2000
105
How can I prevent multiple instances of a DB from opening?
 
no, It is a shared DB, I just have some users that open up multiple instances. The front-end is installed locally the back-end is on the LAN.
 
Something similiar to App.PrevInstance???
 
Here was my solution:

Option Compare Database
Option Explicit
Public Const strLockPath = "C:\GCRDB\" 'db path here
Public Const strLockFN = "AppLock.flg" 'anyname here


Public Sub basLogOutRemove()
On Error Resume Next
Close #1
Kill strLockPath & strLockFN
End Sub

Public Sub basLogOutCheck() As Boolean
On Error Resume Next
basLogOutCheck = Dir(strLockPath & strLockFN) = strLockFN
End Sub

Public Sub basLogOutCreate()
On Error Resume Next
Open strLockPath & strLockFN For Output Shared As #1
End Sub

''paste this into your startup form
Private Sub Form_Load()
On Error Resume Next
Kill strLockPath & strLockFN
If basLogOutCheck Then
Application.Quit
End If
End Sub

''paste this into last form to close
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
basLogOutRemove
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top