locked
Creating a login RRS feed

  • Question

  • User-769911344 posted

    Hi,

    I am working on building a database within MS Access which all the internals are complete but I require a login page to make it secure and only access the appropriate screens/ pages/ forms (due to the different levels of sensitive information within)

    I currently have a login page which is working great, but because I am using this within my work place I can not use it straight from the relationship I have setup (the users table) Here is the code I have currently:

    Private Sub Command25_Click()
    
    
    
    If Len(Me.Username & "") <> 0 And Len(Me.Reference & "") <> 0 Then        '-- There is an entry in the UserName and password
          
          
         If StrComp(DLookup("Reference", "Users", "Username = '" & Username & "'"), Reference, 0) = 0 Then
                '-- Password for this UserName is valid
                   
                   Username.SetFocus
                   If Username = "administrator" Then
                        DoCmd.OpenForm "Splash"
                        
                        
                   ElseIf Username = "manager" Then
                        
                        DoCmd.OpenForm "Splash Manager"
                        
                   ElseIf Username = "sped" Then
                        
                        DoCmd.OpenForm "Splash Sp Ed"
                        
                   ElseIf Username = "ssor" Then
                       
                        DoCmd.OpenForm "Splash SSO R"
                        
                   ElseIf Username = "sso" Then
                        
                        DoCmd.OpenForm "Splash SSO"
                        
                   Else
                        MsgBox "Your Username and/or does not correspond", 16, "Invalid Attempt"
                   End If
                   
          Else
                MsgBox "Invalid Username and/or Password. Try Again.", 16, "Invalid Attempt"
                Me.Username.SetFocus
          End If
          
       
    Else
          MsgBox "Please either re-enter a User Name or Password", 16, "Missing User Name"
          Me.Username.SetFocus
    End If
    
    
    
    End Sub


    I have 3 tables which I have setup - which are required to reflect upon the login:

    Users

    ID, Username, Reference

    tbl_Groups

    ID, Descriptions

    tbl_GroupMembers

    ID, User ID, Group ID

    I am not allowed to have a dirrect relationship within my code to the user table, but I need to get the information from tbl_GroupMembers which only holds/ contains numbers relating to the appropriate Group ID (tbl_Groups) and User ID (Users).

    My reference within Users needs to be a Hash - I currently have not done this, just to ensure I have got everything working first then I'll Hash my code.

    Can you please help?

    Monday, October 7, 2013 8:58 PM

Answers

  • User-734925760 posted

    Hi,

    According to your description, I suggest to create a table, it will contain GroupId and AccessPage.

    We can create a procedure, then we can get GroupId and AccessPage by UserID. As we login, we will know which page we should direct to.

    There is a thread about loging with roles, please refer to the link below:

    http://stackoverflow.com/questions/18619046/asp-net-coding-user-roles-into-login-page

    Hope it’s useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 8, 2013 10:17 PM