The problem with a flag is when your database shuts down inappropriately.
Its status will remain unchanged.
Here's a solution I just discovered using ADO's OpenSchema method for determining add-in connections.
I added this code in a test addon.
Here is the code:
Private Sub cmdTest_Click()
Const JET_SCHEMA_USERROSTER As String = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
Dim cnc As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim countUser As Integer
cnc.Provider = "Microsoft.ACE.OLEDB.12.0"
cnc.Open "Data Source=" & CodeProject.FullName
Set rst = cnc.OpenSchema(adSchemaProviderSpecific, , JET_SCHEMA_USERROSTER)
Me.txtTest = rst.Fields(0).Name & " :" & vbCrLf & vbCrLf
Do Until rst.EOF
Me.txtTest = Me.txtTest & rst.Fields(0) & vbCrLf
countUser = countUser + 1
rst.MoveNext
Loop
rst.Close
cnc.Close
Me.txtTest.SetFocus
End Sub
You can check in the illustration the opening of 2 complements at the same time.
The 3rd connection is that of the VBA code.
If the database is closed improperly, there is no problem.