Removing Write Permission from a User for a Table

This example shows how you can remove all write data permissions for a user or group. It works by first creating a Long Integer value that combines the insert data, replace data, and delete data permissions by using an Or operation. It then uses the And Not operator to reset the appropriate bits in the document’s Permissions property. This has the effect of removing those permissions. Remember that you’re affecting only the user’s explicit permissions with this code. The user may have other permissions due to membership in various groups.

Sub RemoveWritePerms(strDbPath As String, strUser As String, _
		strDocument As String)
	Dim dbs As Database, doc As Document
	Dim lngNoWrite As Long

	Set dbs = OpenDatabase(strDbPath)
	Set doc = dbs.Containers("Tables").Documents(strDocument)
	lngNoWrite = dbSecInsertData Or dbSecReplaceData Or dbSecDeleteData
	With doc
		.UserName = strUser
		' Specify permissions user should not have.
		.Permissions = .Permissions And Not lngNoWrite
	End With
End Sub