Secure parts of a form

  • Thread starter Thread starter Josh
  • Start date Start date
J

Josh

Is it possible to only secure part of a form so different
users can only fill differents parts of the form.

Thanks,
Josh
 
Hi Josh

In the form's Load event procedure, you can show or hide controls depending
on the logged in user (CurrentUser):
Me.txtAnnualSalary.Visible = (CurrentUser="Josh")

Even better, you should create groups reflecting the roles of your different
users. The following function will ascertain whether a user (the current
user by default) is in a given group:

Public Function IsUserInGroup( _
sGroup As String, _
Optional sUser As String) As Boolean
Dim grp As Object
On Error Resume Next
If Len(sUser) = 0 Then sUser = CurrentUser
Set grp = DBEngine(0).Users(sUser).Groups(sGroup)
IsUserInGroup = (Err = 0)
Set grp = Nothing
End Function

You can then check the group instead of the user:
Me.txtAnnualSalary.Visible = IsUserInGroup("PayrollStaff")

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 
Back
Top