Home Forums Microsoft Access Microsoft Access Security in Multiuser environment (Ms Access Project or Ms access database) RE: Security in Multiuser environment (Ms Access Project or Ms access database)

  • I've used the following to restrict user access. Usually by locking controls on a form or making things invisible

    Dim stUser As String

    stUser = GetLoginName

    Select Case stUser

    Case "DAVID", "KATHY", "JO", "Micheal"

    'allow access

    Case Else

    'restrict access

    End Select

    Public Function GetLoginName() As String

    ' Returns the network login name

    Dim lngLen As Long, lngX As Long

    Dim strUserName As String

    strUserName = String$(254, 0)

    lngLen = 255

    lngX = apiGetUserName(strUserName, lngLen)

    If (lngX > 0) Then

    GetLoginName = Left$(strUserName, lngLen - 1)

    Else

    GetLoginName = vbNullString

    End If

    End Function

    GetLoginName returns the current users windows log in. I also have a table with columns for username and boolean columns for privileges such as "Can_Sign_Quote", "Can_Sign_PO". So I can check that table to see if user x has privilege y.

    This works for me because I only have a few users and "real security" isn't a requirement. It's mostly used to prevent people from seeing things they don't want or need to see.