Private Sub cmdInvestigate_Click()
Dim rst As ADODB.Recordset
Dim cat As ADOX.Catalog
Dim grps As Groups
Dim grp As Group
Dim tbl As Table
Dim lngRetValue As Long
'Dim grpthing As Groups
Set rst = New ADODB.Recordset
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.ActiveConnection = CurrentProject.Connection
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
' rst.Open "SELECT Name, Type FROM MSysObjects " _
& "WHERE Type = X " ' Look at Tables, Queries
' Type = 6 > Linked Access Tables
' Type = 5 AND Flags = 112 > PT Query
' Type = 5 AND Flags = 0 > table Query
' Type = 4 > OBDC linked table
' Type = 1 AND Flags = 0 > Table in db
' Type = -32768 > Form
' Type = -32764 > Report
txtResultT = ""
For Each grp In cat.Groups
rst.Open "SELECT Name, Type FROM MSysObjects " _
& "WHERE Type = 4 OR (Type = 1 AND Flags = 0) OR Type = 6 "
While Not rst.EOF
lngRetValue = grp.GetPermissions(rst!Name, adPermObjTable)
If lngRetValue = 0 Or lngRetValue = ((2 ^ 17) + (2 ^ 14)) Then
Else
txtResultT = txtResultT & grp.Name & " : " _
& rst!Name & " : " _
& Interpret(lngRetValue) & " : " _
& lngRetValue & vbCrLf
End If
rst.MoveNext
Wend
rst.Close
Next
txtResultQ = ""
For Each grp In cat.Groups
rst.Open "SELECT Name, Type FROM MSysObjects " _
& "WHERE Type = 5 AND (Flags = 112 OR Flags = 0) "
While Not rst.EOF
lngRetValue = grp.GetPermissions(rst!Name, adPermObjTable)
If lngRetValue = 0 Or lngRetValue = ((2 ^ 17) + (2 ^ 14)) Then
Else
txtResultQ = txtResultQ & grp.Name & " : " _
& rst!Name & " : " _
& Interpret(lngRetValue) & " : " _
& lngRetValue & vbCrLf
End If
rst.MoveNext
Wend
rst.Close
Next
End Sub
Private Function Interpret(lngValue As Long) As String
Const conDeR = 2 ^ 10
Const conDeM1 = 2 ^ 11
Const conDeM2 = 2 ^ 8
Const conDeA1 = 2 ^ 19
Const conDeA2 = 2 ^ 18
Const conDaR = -2147483648# ' 2^31 ( But 2^31 does not work in this contect )
Const conDaU = 2 ^ 30
Const conDaI = 2 ^ 15
Const conDaD = 2 ^ 16
Dim strTempResult
strTempResult = "Design = "
If lngValue And conDeR Then
strTempResult = strTempResult & "R,"
Else
strTempResult = strTempResult & ".,"
End If
If (lngValue And conDeM1) Or (lngValue And conDeM2) Then
strTempResult = strTempResult & "M,"
Else
strTempResult = strTempResult & ".,"
End If
If (lngValue And conDeA1) Or (lngValue And conDeA2) Then
strTempResult = strTempResult & "A,"
Else
strTempResult = strTempResult & ".,"
End If
strTempResult = strTempResult & " : Data = "
If lngValue And conDaR Then
strTempResult = strTempResult & "R,"
Else
strTempResult = strTempResult & ".,"
End If
If lngValue And conDaU Then
strTempResult = strTempResult & "U,"
Else
strTempResult = strTempResult & ".,"
End If
If lngValue And conDaI Then
strTempResult = strTempResult & "I,"
Else
strTempResult = strTempResult & ".,"
End If
If lngValue And conDaD Then
strTempResult = strTempResult & "D,"
Else
strTempResult = strTempResult & ".,"
End If
Interpret = strTempResult
End Function