View Full Version : Limit user's security permission with code


Autoeng
09-15-2005, 04:57 AM
My db is secured using Access security but now find myself needing to code a little security work around if possible.

I have a form that has a subform. On the subform is a field named "Comments". The subform security only lets a particular group write to the fields it contains (including "Comments"). I have a new user that I need to allow to write to "Comments" but not to any of the other fields on the subform. I could make another subform with "Comments" only field and redo my security so that the original group can write to both subforms and new user can only write to "Comments" subform but I think it might be easier to code in that the new user is only allowed to write to field "Comments" in the existing subform. Every user logs into the db so I can get the user ID.

Is it possible to do this?

Smart
09-16-2005, 12:35 AM
If you have the user Id (currentuser) then you can can disable or enable the comments field
EG (in the on load or on open of the form)

Dim UserLoggedIn as string

UserLoggedIn = currentuser()

If UserLoggedIn = "required user name" Then
Commentsbox.enabled = true
Else
Commentsbox.enabled = False
End if

Autoeng
09-16-2005, 04:54 AM
Would this not disable everyone else who does have rights to write to the "Comments" field?