User's permission on a form

We have an old Access mdb split database.  The user's log into the system via the mdw form (users and permissions functionality).

My question is this...  We want all user's to have permission to use a particular form but for employees that log in as "shop", only one of the tabs on the form should be usable for them (read/write permission).  The other tabs have to be read-only.

How can this be done?

--Steve
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
So you're using ULS for this?

If so, you can check the current user's group membership, and allow/deny functionality based on that:
Msgbox DBEngine.Workspaces(0).Users(CurrentUser).Groups("YourGroupName").Name = CurrentUser

Open in new window


If that MsgBox returns True, the user is a member of "YourGroupName". If False, they are not a member.

So you could enable/disable your Tab page like this:

'/ enabled if the user is a member of "YourGroupName"
Me.YourTabPage.Enabled = DBEngine.Workspaces(0).Users(CurrentUser).Groups("YourGroupName").Name = CurrentUser

Open in new window

0
SteveL13Author Commented:
Will that then enable all the fields on the tab on the form?  And where does the line of code go...

Me.YourTabPage.Enabled = DBEngine.Workspaces(0).Users(CurrentUser).Groups("YourGroupName").Name = CurrentUser

In the onopen event of the form?

--Steve
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I'd think the Open or Load event of the Form would be sufficient, but that depends on your needs.
Will that then enable all the fields on the tab on the form?
It enables or disable the Tab Page:

Me.YourTabPage.Enabled

This means the user cannot interact with that page.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If you need the users to be able to view the data on the tabs, you may have to take this a step further, and iterate through the Controls collection to set the Enabled and Locked properties of the controls. To do that:

1) Add a value in the Tag property of each control. This is done to "group" the controls together so that you can take action against a group of them.

2) Loop through the Controls collection and set the Enabled and Locked properties as needed.

For example:

If I have set the tag to "S" for all controls where Shop employees should be allowed to Edit:

Dim ctl As Control

On Error Resume Next
For Each ctl in Me.Controls
  ctl.Enabled = ctl.Tag = "S"
  ctl.Locked = ctl.Tag <> "S"
Next ctl

This would Enable any control where the Tag value is "S", and it would Lock any control where the Tag is NOT "S"
0
SteveL13Author Commented:
Sorry for the delay.  When I paste this line...

Msgbox DBEngine.Workspaces(0).Users(CurrentUser).Groups("Shop").Name = CurrentUser

into the immediate window  I get:

Runtime error 3265  -  Item not found in this collection

??
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Sorry about that ... I was looking back through an older application where I used ULS, and found this:

Function IsUserInGroup(NameOfGroup As String) As Boolean
	Dim wrk As Workspace
	Set wrk = DBEngine.Workspaces(0)

	On Error Resume Next
	IsUserInGroup = (wrk.Users(CurrentUser).Groups(NameOfGroup).Name = NameOfGroup)

	Set wrk = Nothing
End Function

Open in new window


You'd call it like this:

If IsUserInGroup("SHOP") Then
  '/ user is in the SHOP group
Else
  '/ user is not in the SHOP group
End If

Or:

Me.TabPage.Enabled = IsUserInGroup("SHOP")

Or use the loop method I described earlier if you need to enable/disable specific controls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.