Restrict multiple logins with single username at sametime in ms access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuvang
    New Member
    • Oct 2008
    • 20

    Restrict multiple logins with single username at sametime in ms access

    Hi all

    I have a mdb with login name and password form. There are several login names, i defined through a table "User_login ". Here the problem is at a time a single user is able to login in multible system, which i want to restrict.

    here is the code which i i am using for login check.....

    Code:
    Private Sub cmblogin_Click()
    
    Static intlogonattempts As Integer
    
    'Check to see if data is entered into the UserName combo box
    
        If IsNull(Me.cmbname) Or Me.cmbname = "" Then
          MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.cmbname.SetFocus
            Exit Sub
        End If
    
        'Check to see if data is entered into the password box
    
        If IsNull(Me.cmbpass) Or Me.cmbpass = "" Then
          MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
            Me.cmbpass.SetFocus
            Exit Sub
        End If
    
        'Check value of password in tblEmployees to see if this
        'matches value chosen in combo box
        
      
          
            If Me.cmbpass.Value = DLookup("Password_login", "user_login", "[id]=" & Me.cmbname.Value) Then
            
            
                emp_name = Me.cmbname.Value
                
                intlogonattempts = 0
            
                'Close logon form and open splash screen
    
                cmbname.SetFocus
                Me.Visible = False
                DoCmd.OpenForm "As Laid Backlog Digitization Database"
            
            
            Else
              intlogonattempts = intlogonattempts + 1
            
              If intlogonattempts > 3 Then
                MsgBox "Sorry! You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
                Application.Quit
            
             End If
            
              MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
              Me.cmbpass.SetFocus
          
              End If          
    End Sub

    can anyone please help on this..........


    Regards
    yuvan

    <E-mail address removed>
    Last edited by Stewart Ross; Oct 7 '08, 09:36 AM. Reason: mail address removed from post for poster's own protection; code tags added to code
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    You don't say :
    What problem you're having.
    What error messages you're getting.
    What line the error message is on.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Assuming [cmbName] holds a string value, try changing line #26 of your code to :
      Code:
      If Me.cmbPass = DLookup("Password_login", "user_login", "[id]='" & Me.cmbname & "'") Then

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        To ensure the same user only logs in once at a time, add a field into your [User_Login] table that indicates if the user is currently logged in. You will need to set it to TRUE after a successful login, and test for that too when checking the name and password.

        You will also need a facility to reset any or all names in case the system crashes at any point.

        Comment

        • yuvang
          New Member
          • Oct 2008
          • 20

          #5
          Hi Neopa,

          My problem is a person with the login name "A" is able to login into "N" number of systems at a time. i want to restrict that through VB code. Can you please help on this...........

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32661

            #6
            Originally posted by NeoPa
            You don't say :
            What problem you're having.
            What error messages you're getting.
            What line the error message is on.
            You answer none of my questions. You don't respond to (ignore) the help I've already posted. Now you want me to start again from scratch.

            I understand your basic problem. I need you to respond to my posts before I spend any more time on this. Is that too much to ask? It is your question after all.

            Comment

            • yuvang
              New Member
              • Oct 2008
              • 20

              #7
              Sorry.... I was out of internet facility for one week at the time of your reply. So that i couldn't able to response to you in right time........... .....

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                Timing is not a problem, but when you do reply, I still need you to answer the questions. Without all those answers I am unable to help further.

                Comment

                • yuvang
                  New Member
                  • Oct 2008
                  • 20

                  #9
                  Originally posted by NeoPa
                  What problem you're having.
                  Problem that is a person is able to login in several systems by using same login. That I want to restrict....... ...
                  Originally posted by NeoPa
                  What error messages you're getting.
                  No error messages.
                  Originally posted by NeoPa
                  What line the error message is on
                  All the lines are working fine. I gave th code just for your reference.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32661

                    #10
                    Thank you. Now we can progress.

                    The next question then (in response to the information) is what did you think about post #4. It seems to me this may well be a solution to the problem you've described.

                    Comment

                    • yuvang
                      New Member
                      • Oct 2008
                      • 20

                      #11
                      i too thing that will work. But i don't know how to do that..........

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32661

                        #12
                        OK Let's take this step by step.

                        Do you have a table of accounts that can be used to log on? What is its name?

                        Comment

                        • yuvang
                          New Member
                          • Oct 2008
                          • 20

                          #13
                          Table name is "user_login "

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32661

                            #14
                            Sorry, that info was already available from the OP (Original Post). Never mind.

                            The next question is :
                            What are the names of all the fields you have in that table now?

                            This will work much better if you can post the meta-data (info about the layout / structure) of the table in the same way as I use in my example. Click on the Reply button and you will have access to all the codes I've used. PK & FK stand for Primary Key & Foreign Key respectively. Never use TABs in this as the layout gets mucked up. Use spaces and all is fine.
                            Table Name=[User_Login]
                            Code:
                            [I]Field           Type      IndexInfo[/I]
                            UserID          AutoNumber    PK
                            Account         String      Unique
                            Password        String
                            FullName        String
                            InUse           Boolean
                            This example is a basic layout and includes the items you will need ([FullName] not ABSOLUTELY necessary). You need to post what you have in your table in this layout.

                            Comment

                            • yuvang
                              New Member
                              • Oct 2008
                              • 20

                              #15
                              Hi

                              here is my table detail

                              Table Name=[User_Login]
                              Code:
                              [I]Field             Type      IndexInfo[/I]
                              ID                Number        PK
                              EMP_NAME          String      Unique
                              Password_Login    String
                              InUse             Boolean

                              Comment

                              Working...