Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2014

    Question Unanswered: How to create Users Authority

    Hello everyone
    I finish my database in access 2013 but I have problem
    I have in this program many Authority levels 4 or 5 levels
    (Admin ,manager ,Assistant manager and User)
    how I can create Authority form
    if my user name and password for admin go to admin page directly or manger go to manager form ....... etc.
    thanks a lot and best regards

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    Don't waste your time with a login form: each user is identified by his/her Windows login. You can retrieve the information using:
    UserName = Environ("USERNAME")
    or by using APIs (see in the codebank:
    Create a table that contains the authorised users and their level of privilege.
    All you need now is to call a procedure (from an AutoExec macro) that retrieves the level of privilege of the current user and opens the appropriate form:
    Function OpenUserForm()
        Dim lngLevel As Long
        lngLevel = Nz(DLookUp("Level", "Tbl_Users", "UserName = '" & Environ("USERNAME") & "'"), 0)
        Select Case lngLevel
            Case 1    ' User
                DoCmd.OpenForm "UserForm" ' , options if needed.
            Case 2    ' Manager 
                DoCmd.OpenForm "Manager Form" ' , options if needed.
            Case 3    ' Assistant
                DoCmd.OpenForm "AssistantForm" ' , options if needed.
            Case 4    ' Admin
                DoCmd.OpenForm "AdminForm" ' , options if needed.
            Case Else
                MsgBox "You are not allowed to use this application", vbInformation, "Access denied"
        End Select
    End Function
    Have a nice day!

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    traditionally a computer based security system is based on users belonging to groups
    permissions are allocated to those user groups
    a user can belong to many groups
    when retrievng the permissions retrieve for the user group, or iterate through the user groups the current ember is part of and returnt he highest or matching permissions

    environ('username') is 'good', but its easily spoofed, and easily bolluxed, retrieving the network sign on is in my view far better. I have seen an Access application (admittedly they used netware as their networking software) fail to logon to the network but the environ variable was set.

    I woudl also place my code to check permissions within each object (effectivley place some code int he on open event and set cancel = true if they do not have sufficient permissions

    IIRC I used a function that requested the permission and returned a boolean value indicating if the user had the correct permission
    it pushes the code to validate into each object so there i sno need to to remember to request permission in menus or switchboards
    the only downside is that users instead of not seeign an option they dont' have clearance to which woudl be my preferred choice as opposed to gettign a bounce message.. you donjt' have adequate permission
    Last edited by healdem; 02-23-14 at 14:35.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Feb 2014
    thank you a lot (Sinndho and healdem) I will try it
    best regard

  5. #5
    Join Date
    Mar 2009
    Provided Answers: 15
    You're welcome!
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts