Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    175

    Thumbs up Unanswered: User Security Access 2010 Split Database

    Hello. I have a 2010 Microsoft Access Database. I have split the database, it is fully functional, and has about 8-9 users. I am the administrator for all intents and purposes.

    I've recently begun thinking about adding user permissions and/or requiring users to enter passwords in order to access the database, (as the db is becoming more complex and user-friendly).

    As I've indicated, the database is split into a front and back end.

    Does anyone have any suggestions (in layman terms for the novice)
    , as how best to go about adding a level of security?

    If so, please provide any detailed instruction that could help me get started, should I decide to go this route.
    Thank you very kindly in advance.

  2. #2
    Join Date
    Nov 2012
    Posts
    79
    I ran into the same issue building my database. What I ended up doing is writing a procedure that gets the username of the person currently logged into the computer, and based on that return, it compares the returned name to the name previously placed in a table along with a "security level" (1-4) 4 being the super user and 1 being general user. And then I enable or disable functions based on what level returns.

    I thought about the password, but I figure if the user has to log into the computer through a network, there's no reason to make them log into the database as well. My database requires some sort of security, but the network takes care of that for me already.
    Version: Access 2010

  3. #3
    Join Date
    Nov 2012
    Posts
    79
    Specifically place this code in your home forms open event:
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
    Dim varResponse As Variant
    
    varResponse = MsgBox("You are currently logged into this computer as: " & " " & ReturnUserName & vbCrLf & vbCrLf & "If this is incorrect, please press cancel, logout the current" _
                  & vbCrLf & "user and login with your credentials" & vbCrLf, vbOKCancel)
    
        If varResponse = vbOK Then
        Exit Sub
        
        ElseIf varResponse = vbCancel Then
            DoCmd.Quit
        End If
        
        
    
    End Sub
    And place this code in a module:

    Code:
    Public Declare Function GetUserName Lib "advapi32.dll" Alias _
                            "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    
    Public Function ReturnUserName()
    
    Dim strUser As String, X As Integer
    
    strUser = Space$(256)
    
    X = GetUserName(strUser, 256)
    
    strUser = RTrim(strUser)
    ReturnUserName = Left(strUser, Len(strUser) - 1)
    
    End Function
    I pulled that information from somewhere on the internets..not sure where though.
    Version: Access 2010

  4. #4
    Join Date
    Oct 2010
    Posts
    175
    Okay I think I understand. But, what do you mean by placing the second set of code in a "module"?

    Also when I placed the first set of code into the form's open event it return only a message. See attachment. is that what it's supposed to do? Thank you.
    Attached Thumbnails Attached Thumbnails msg.jpg  

  5. #5
    Join Date
    Nov 2012
    Posts
    79
    Were your computer set up on a network that required the users to log in to Windows, that message would return the username of the person currently logged into the computer. I.E.
    "You are currently logged in as cdoopyschmitt" A table, which I called users has a column for the username of the people who are going to be logging into the computer to use the database and a column for userlevel which will be 1 through 4. 4 being the highest authorization. You can then enable or disable certain functions of your database depending on what level the person is.

    Is it super secure? No. But it works for my needs because of the nature of the people I work with.

    By placing the code in a module I mean goto create and all of the way to the right you'll see Module, Class Module and Macro (or something). Click Module, copy and paste the code and save it as something, the name doesn't really matter.

    The first code simply pops a message up and reminds the user who's logged in, and if it's not them, log out of windows and log back in under their stuff. It uses the function ReturnUserName to get the username of the person logged in.

    The reason your screenshot doesn't include the name is because you haven't added the 2nd code (the function ReturnUserName) into a module...so essentially the first code is calling a function that doesn't exist yet.
    Version: Access 2010

  6. #6
    Join Date
    Oct 2010
    Posts
    175
    Okay. How do I apply the module to the form?

  7. #7
    Join Date
    Nov 2012
    Posts
    79
    In the forms design mode, in the properties window, under the events tab, find the open event, click the ... to the right, select event procedure...copy paste

  8. #8
    Join Date
    Oct 2010
    Posts
    175
    Thanks, I'll give it a shot. I really appreciate your input.

Posting Permissions

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