User permissions in Access 2010

How do you create permissions in Access so user "A" and edit data, but user "B" can only view data?
rrhandle8Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Nothing is built into Access to handle that.

 Some add a security system in the form of a couple of tables.  One for forms, with a permission flag for Open, Add, Edit, and Delete, and another for controls, with flags for enabling/disabling the controls.

The other way to do it is use a different data store rather than the ACE database engine.  Something like SQL Server, which allows for security on tables and views to be set by user and/or group.

 That doesn't really touch objects though, so most build something in Access.

Jim.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Here's an addon that will do something like that:

http://www.peterssoftware.com/las.htm

As Jim said, it won't do anything for actual data security (users could still go directly to your tables and edit data there), but it does make things a bit easier to control in regard to what users can do on your Forms and such.

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
rrhandle8Author Commented:
Thanks guys.  I wonder if I can make this simple.  There are only two user types: full permissions and read only.  Based on the user's login information could I make the database readonly?  Or maybe use a second database just for logging in, and open the database as readonly for particular users?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can set all of your Forms to be ReadOnly when opening them like this:

Me.AllowEdits = False
Me.AllowAddition = False
Me.AllowDeletes = False

This would allow the user to view data, but not modify it.

Of course, if you're allowing users access to your Tables or Queries, then you have no control over that.
rrhandle8Author Commented:
Scott, possible to loop through all forms when database opens, and set the properties you stated?
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You just write them in the Open or Load event of the Form, based on the user login. In most cases, you'd have a hidden form somewhere that would store your "User Level", and your forms could refer to that:

If Forms("Hidden_Form").txtUserLevel > 1 Then
  Me.AllowEdits = True
  Me.AllowDeletes = True
  ect ect
Else
  Me.AllowEdits = False
  etc etc
End If

Or you can do this:

Me.AllowEdits = Forms("Hidden_Form").txtUserLevel > 1

This would set AllowEdits to TRUE if the Userlevel is greater than 1, otherwise it would set it to FALSE.
PatHartmanCommented:
I prefer to use a procedure that locks the individual controls.  This allows the users access to search and filter functions.  If you always want a particular control to be unlocked or locked regardless of the value of bLock, then add either "Lock" or "NoLock" to the tag property.

this code can be used as is.  Add it to a standard module and call it from the Current event of each form you want to control.
If ..... code to determine read only
    Call LockControls(Me, True)
Else
    Call LockControls(Me, False)
End If

Open in new window

Public Sub LockControls(frm As Form, bLock As Boolean)
    Dim ctl As Control
    For Each ctl In frm.Controls
    Select Case ctl.ControlType
        Case acTextBox, acComboBox, acListBox, acCheckBox
            Select Case ctl.Tag
                Case "NoLock"
                    ctl.Locked = False
                Case "Lock"
                    ctl.Locked = True
                Case Else
                    ctl.Locked = bLock         'toggle locks
            End Select
        Case acOptionGroup, acOptionButton, acCheckBox      ''not working
             Select Case ctl.Tag
                Case "NoLock"
                    ctl.Locked = False
                Case "Lock"
                    ctl.Locked = True
                Case Else
                    ctl.Locked = bLock         'toggle locks
            End Select
        Case acCommandButton
            Select Case ctl.Tag
                Case "NoLock"
                    ctl.Enabled = True
                Case "Lock"
                    ctl.Enabled = False
                Case Else
                    ctl.Enabled = Not bLock         'toggle locks
            End Select
    End Select
Next ctl
Set ctl = Nothing
End Sub

Open in new window

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.