I'm working at a company as an intern. I never used vba in my life before. I need to display if the MS Access database was opened in exclusive mode at the user's computer. It needs to has some kind of red indicator if the user is opened with exclusive mode in any other case it should display a green indicator. The Access is used in shared mode.
Edit: I found this on a Hungarian page. (link to the page: https://prog.hu/tudastar/101971/access-megnyitasi-opciok-lekerdezese-vba-ban)
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 DAO.Database
Dim hFile As Integer
hFile = FreeFile
Set db = CurrentDb
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
I don't know where I should put to try it out, if it even works or good.