How to make an Access login with rights to user information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anewbornman
    New Member
    • May 2010
    • 3

    #1

    How to make an Access login with rights to user information

    I want to create a login form for multiple users with different rights, and they can only see information in my queries and reports that pertain to them. For example: User1 logins in, on the switchboard I only want user1 to be able to see certain things. Then when user1 goes to see a report, it only shows user1, user1's information.

    Now by what I have read and can gather, I will need a user table, and that table will have to have their username, password, and a rights level, but I have no idea how to put all of that into code in VBA to make it happen.
    Last edited by Niheel; May 26 '10, 12:45 PM. Reason: edited out non-question details
  • fdfjc
    New Member
    • May 2010
    • 8

    #2
    Capture userid and enable/disable buttons

    Hi newbornman, here's how I've handled this. On my main form (or switchboard) I capture the user's login and enable/disable, show/hide the boxes, forms and buttons I want each to have access to.

    Code:
    Dim usernm As String
    usernm = Environ("USERNAME")
    'Debug.Print usernm
    If (usernm = "JohnSmith" Or usernm = "JoeSmith") Then
    
    Me.txtReadOnly.Visible = False
    Me.txtReadOnly.Enabled = False
    Me.txtRecursive.Visible = True
    Me.txtRecursive.Enabled = True
    Me.txtRecursive.SetFocus
    Me.AllowAdditions = True
    Me.AllowEdits = True
    Me.AllowDeletions = True
    Me.btnOpenEditLog.Visible = True
    Me.btnOpenEditLog.Enabled = True
    Last edited by Niheel; May 27 '10, 03:37 AM. Reason: placed code in tags

    Comment

    • anewbornman
      New Member
      • May 2010
      • 3

      #3
      how to make an access login with rights to user information

      Ok, so I need to take that code and put it into my VBA module, and then attach it to my login form? Does this make it to where one part of the company can only see their information? The reason I ask this, is because I am trying to make this for a company that has many parts.
      For Example:
      There are 8 companies. Company A, B, C, D, so on so forth.
      There is one table with everyones information, and a whole bunch of queries and reports.
      Company A logs on and goes to look at the reports. I want Company A to be able to only see Company A's information and not company B, or C or what anyone else.

      If this code works then I apologize but like I said before I am new to this. Thanks for the help.

      Comment

      • fdfjc
        New Member
        • May 2010
        • 8

        #4
        I guess part of it depends also on the version of Access you are using. 2007 no longer has user-level security, so this has been my work-around, but I am dealing with only a few users. You could take that table with everyone's names and assign a permission level to each. For instance

        NAME PERMISSIONS
        Pam Company A
        Greg Company A
        Sam Company B

        So when username is Pam or Greg, you enable and make visible only Company A forms, buttons, text boxes, etc. And you can also the send value 'Company A' into a variable to be used as the where condition when you open those forms so that they only see Company A data. I could send you that code later if you would like to see it--I forgot my laptop and someone is bringing it to me soon.

        Comment

        • anewbornman
          New Member
          • May 2010
          • 3

          #5
          Yes please for the code. As for everything else, thank you very much.

          Comment

          Working...