Results 1 to 4 of 4
  1. #1
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26

    Login Form. Passwords work for any User Name?

    I know there are a million posts on here about login forms, which is where I got most of the code for mine. I have a combo box for all of the UserNames in my database. The user names are derived from a Query (Security_Q). They are made by default as the First initial, Last name of the employee.



    The problem I have is, if I change a password for an employee, that password works for any given username. For example, if my password is 'ABC', and employee can use their login, and use ABC as a password, and it works. I have attached the code below.

    Hopefully someone has a solution for me. This has been driving me crazy over the last week. Thanks a lot everyone!

    Private Sub Login_Click()
    Dim strFilter As String, strAdmin As String
    Call Employee.SetFocus
    If IsNull(Me.Employee) Then
    MsgBox "Please enter Username and Password", vbCritical, "Login Error"
    Exit Sub
    End If
    Call Password.SetFocus
    If IsNull(Me.Password) Then
    MsgBox "Please enter Username and Password", vbCritical, "Login Error"
    Exit Sub
    End If

    strFilter = "(([Employee]='%U') AND ([Password]='%P'))"
    strFilter = Replace(strFilter, "%U", Me.Employee)
    strFilter = Replace(strFilter, "%P", Me.Password)
    strAdmin = Nz(DLookup("[ID]", "[Security_Q]", strFilter), "Fail")
    If strAdmin = "Fail" Then
    MsgBox "Incorrect Username or Password"
    Else
    DoCmd.Close
    DoCmd.OpenForm ("ASSIST")
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Have you step debugged? I am not familiar with use of the %. What are %U and %P?

    Could try:

    If Nz(DLookup("ID", "Security_Q", "Employee='" & Me.Employee & "' AND Password='" & Me.Password & "'"), "Fail") = "Fail" Then
    ...

    Do you want to enforce case distinction - so a <> A?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    161
    I think the problem is at
    DLookup("[ID]", "[Security_Q]", strFilter), "Fail")
    The Security_Q Query need to be filter by the user Employee such as
    In criteria field of Employee add Forms]![ForM_Name]![Employee]
    That will Filter Employee and check it's pasword

  4. #4
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    In the link below, there is a sample DB on Security levels. I am actually using that in my DB. You can incorporate it in yours if you deem necessary.

    https://www.accessforums.net/sample-...ent-20745.html

    If you find it good, I can assist you navigate through it since i some how master it now.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Login Form/User ID Trouble.
    By Addanny in forum Forms
    Replies: 2
    Last Post: 07-03-2013, 10:25 AM
  2. HELP>Access 2010 User Login Form Code.
    By zaaimanm in forum Programming
    Replies: 5
    Last Post: 10-22-2012, 07:28 PM
  3. User Login Form
    By glen in forum Forms
    Replies: 21
    Last Post: 09-17-2012, 09:09 AM
  4. User Passwords not recognised in Access 2010
    By Philm in forum Programming
    Replies: 2
    Last Post: 05-09-2012, 08:06 AM
  5. Setting up User names and passwords
    By knightjp in forum Security
    Replies: 2
    Last Post: 02-05-2009, 10:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums