Secure parts of a form

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
 
G

Graham Mandeno

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top