Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-16-2018, 06:40 AM   #1
akika
Newly Registered User
 
Join Date: Aug 2018
Posts: 12
Thanks: 6
Thanked 0 Times in 0 Posts
akika is on a distinguished road
how to change fields values by only the admin in access2016

hi,
Pls help.
in access 2016, I have field ' assigned_to' & 'project_cost' in the database and form.
how can i make this these fields be amendable by only the admin user.

for security level, i have admin, normal user.. both of these user type will have access with the form containing these fields but only admin need to change those.

akika is offline   Reply With Quote
Old 09-16-2018, 06:51 AM   #2
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 12,167
Thanks: 57
Thanked 1,124 Times in 1,026 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: how to change fields values by only the admin in access2016

Akika,

To accomplish this, you need to set up the DB so that your users NEVER see the infrastructure i.e. the ribbon and object navigation panel. You need to have a table of usernames and then associate the usernames to specific roles.

The payoff is that if you have that, then on the relevant form, in that form's OnLoad event, you could put code that set .Locked=True or .Locked=False based on the user's role. e.g. in the form's class module:

Code:
Private Sub Form_Load()

Dim UName as String
Dim URole as Long

...
    UName = Environ("Username")
    URole = DLookup( "[UserRole]", "usertable", "[UserRole]='" & UName & "')

    IF URole = 1 Then
        [Assigned_To].Locked = FALSE
        [Project_Cost].Locked = FALSE
    Else
        [Assigned_To].Locked = TRUE
        [Project_Cost].Locked = TRUE
    End If

End Sub
You can embellish this, but the assumption is that admin role code is 1 and the normal user role code is something else (including 0 and not defined). So you look up the user's role and if it is 1, unlock things. If not, lock them.

You can search this forum for "Securing a database" to see the kinds of things you need to do to prevent your users from getting into the innards of the DB. If you don't do this, you CANNOT protect those data items.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.

Last edited by The_Doc_Man; 09-16-2018 at 07:04 AM.
The_Doc_Man is offline   Reply With Quote
The Following User Says Thank You to The_Doc_Man For This Useful Post:
akika (09-16-2018)
Old 09-16-2018, 06:53 AM   #3
MarkK
Super Moderator
 
MarkK's Avatar
 
Join Date: Mar 2004
Location: Vancouver BC
Posts: 7,761
Thanks: 10
Thanked 1,285 Times in 1,224 Posts
MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all
Selectively lock or disable the controls based on the security level of your user. You have not told us anything about how your user is represented in your data so this is a guess, but something like...
Code:
Private Sub Form_Open(Cancel as Integer)
    ' lock...
    Me.AssignedTo.Locked = Not YourSystemUser.SecurityLevel = "Admin"
    ' or disable...
    Me.ProjectCost.Enabled = Your SystemUser.SecurityLevel = "Admin"
End Sub
hth
Mark

__________________
formerly known as lagbolt | Windows 10 | Access 2010 | Visual Studio 2013 | "Institutions have a vested interest in perpetuating the problems to which they are the solution." - Clay Shirky
MarkK is offline   Reply With Quote
The Following User Says Thank You to MarkK For This Useful Post:
akika (09-16-2018)
Reply

Tags
access , form access , vba access 2016

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access2016 and dbase iii leonardo.massei Modules & VBA 6 11-10-2016 06:43 AM
Change System Date/Time in vba without Admin Privileges BiigJiim Modules & VBA 2 04-01-2014 01:58 AM
is it possible to change the values of checked/unchecked boxes in yes/no fields? chosch Modules & VBA 7 04-14-2008 12:26 AM
How to change fields' default values from a form? robfal Forms 2 08-31-2002 05:43 AM
Admin lost admin rights pne987 General 1 07-30-2002 08:14 AM




All times are GMT -8. The time now is 06:32 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World