Access Database Security Question

前端 未结 5 1373
野趣味
野趣味 2021-01-26 15:01

I have a database in Access 2003 that I only want certain people to be able to access. In my database I have a table which lists the people that should be able to access the da

5条回答
  •  萌比男神i
    2021-01-26 15:42

    This is the Access security window dressing I use.

    Public Function SecurityCode() 
    '*  Purpose:    Limits access to program
    
        Dim sUserID    As String
        Dim sUserName   As String    
    
    '*  Determines user from Windows Login
        sUserID = Environ("USERNAME")
    
    
    '*  Lookup on BE table of Allowed Users to verify on the list.
         sUserName = DLookup("[UserName]", "tbl_AllowedUsers", "ID = '" & sUserID & "'")
    
    
    If Len(sUserName) > 0 Then
        'Allowed User, opens Main Switchboard
    
        'Set global variable for Admin rights
        g_Admin = DLookup("[AdminRights]", "tbl_AllowedUsers", "ID = '" & sUserID & "'")
    
        DoCmd.OpenForm "Switchboard"
        DoCmd.SelectObject acForm, "Switchboard", True
        DoCmd.RunCommand acCmdWindowHide
    
    Else
        'Not on the Allowed Users list, opens to a Password Page
        DoCmd.OpenForm "frm_LockPage"
        DoCmd.SelectObject acForm, "frm_LockPage", True
        DoCmd.RunCommand acCmdWindowHide
    End If
    
    
    End Function
    

提交回复
热议问题