Article ID: 117539
Article Last Modified on 1/19/2007
Option Explicit
Function IsCurDBExclusive () As Integer
' Purpose: Determine if the current database is open exclusively.
' Returns: 0 if database is not open exclusively.
' -1 if database is open exclusively.
' Err if any error condition is detected.
Dim db As Database
Dim hFile As Integer
hFile = FreeFile
Set db = dbengine.workspaces(0).databases(0)
If Dir$(db.name) <> "" Then
On Error Resume Next
Open db.name For Binary Access Read Write Shared As hFile
Select Case Err
Case 0
IsCurDBExclusive = False
Case 70
IsCurDBExclusive = True
Case Else
IsCurDBExclusive = Err
End Select
Close hFile
On Error GoTo 0
Else
MsgBox "Couldn't find " & db.name & "."
End If
End Function
If IsCurDBExclusive()=True Then Msgbox "It's Exclusive!"
Keywords: kbhowto kbprogramming kbusage KB117539