Please help me with limiting user view

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Please help me with limiting user view

    I've developed a database that will be used by my team (25 people)
    The database is based on the Resource Planner template

    The database will reside on a shared drive.
    What I'd to do now is create some sort of entry point into the
    database that only shows the users records they own.

    So I was thinking when the database opens the user selects their name.
    Then the switchboard opens but no matter what they select from the
    switchboard only records that have the same name as the name selected
    at open will be displayed.

    I don't need any sort of password protect

    How should I do this?

    Thanks
    Steve J
  • Roger

    #2
    Re: Please help me with limiting user view

    On Oct 24, 12:22 pm, Steve <dafella...@yah oo.comwrote:
    I've developed a database that will be used by my team (25 people)
    The database is based on the Resource Planner template
    >
    The database will reside on a shared drive.
    What I'd to do now is create some sort of entry point into the
    database that only shows the users records they own.
    >
    So I was thinking when the database opens the user selects their name.
    Then the switchboard opens but no matter what they select from the
    switchboard only records that have the same name as the name selected
    at open will be displayed.
    >
    I don't need any sort of password protect
    >
    How should I do this?
    >
    Thanks
    Steve J
    create a table called tblUser
    userId autonumber pk
    userName
    userLogin


    create a module called mNtuser, to get their windows login containing,
    this

    Option Compare Database
    Option Explicit

    Declare Function GetUserName& Lib "advapi32.d ll" Alias
    "GetUserNam eA" (ByVal lpBuffer As String, nSize As Long)

    Public Function ntUserName() As String
    Dim s$, cnt&, dl&, sz&

    cnt& = 255
    s$ = String$(255, vbNullChar)
    dl& = GetUserName(s$, cnt&)
    If (Asc(Mid$(s$, cnt&, 1)) = 0) Then
    cnt& = cnt& - 1
    End If

    ntUserName = UCase(Left$(s$, cnt&))
    End Function


    public function userId as long
    userId = nz(dlookup("use rId","tblUser", "userLogin = '" &
    ntusername() & "'"),-1)
    end function


    use = userId() in all your queries as a condition on the userId field
    to return all records belonging to that user

    Comment

    • Roger

      #3
      Re: Please help me with limiting user view

      On Oct 24, 1:49 pm, Roger <lesperan...@na tpro.comwrote:
      On Oct 24, 12:22 pm, Steve <dafella...@yah oo.comwrote:
      >
      >
      >
      >
      >
      I've developed a database that will be used by my team (25 people)
      The database is based on the Resource Planner template
      >
      The database will reside on a shared drive.
      What I'd to do now is create some sort of entry point into the
      database that only shows the users records they own.
      >
      So I was thinking when the database opens the user selects their name.
      Then the switchboard opens but no matter what they select from the
      switchboard only records that have the same name as the name selected
      at open will be displayed.
      >
      I don't need any sort of password protect
      >
      How should I do this?
      >
      Thanks
      Steve J
      >
      create a table called tblUser
          userId   autonumber pk
          userName
          userLogin
      >
      create a module called mNtuser, to get their windows login containing,
      this
      >
      Option Compare Database
      Option Explicit
      >
      Declare Function GetUserName& Lib "advapi32.d ll" Alias
      "GetUserNam eA" (ByVal lpBuffer As String, nSize As Long)
      >
      Public Function ntUserName() As String
          Dim s$, cnt&, dl&, sz&
      >
          cnt& = 255
          s$ = String$(255, vbNullChar)
          dl& = GetUserName(s$, cnt&)
          If (Asc(Mid$(s$, cnt&, 1)) = 0) Then
              cnt& = cnt& - 1
          End If
      >
          ntUserName = UCase(Left$(s$, cnt&))
      End Function
      >
      public function getUserId as long
         userId = nz(dlookup("use rId","tblUser", "userLogin = '"  &
      ntusername() & "'"),-1)
      end function
      >
      use = userId() in all your queries as a condition on the userId field
      to return all records belonging to that user- Hide quoted text -
      >
      - Show quoted text -
      Steve
      in response to your email, I'll post here so others can participate

      The tbluser has the person's name and windows login (ntlogin)

      If you don't know their windows login, you need to use ms-access
      workgroup security, or have no security

      Just having users select their name from a list is not a good idea,
      cause I can choose your name, and see your records

      since I don't have your table layout, I don't know how you identify
      who records belong to who, I'm assuming it's an ID of some sort...
      that ID and userId in tblUser is the same

      the function ntUserName() gets your windows login
      the function getUserId (I've renamed it from just 'userId') translates
      the windows login to an ID that can be used to select records

      so if your table is called tblResource with
      resourceId autonumber pk
      userId
      resource

      your query would be
      SELECT * FROM tblResource WHERE userId = userId()

      if I'm logged in, this will show my resources
      and if you're logged in, yours


      hope this helps

      Comment

      Working...