title: Excel VBA LogIn Form with Stored Passwords on Access Database
body: <p>I want to validate my Userfrom password with the one stored in Access Database, when I run my code below, I didn't receive any errors, however, when I try to put a wrong password, it says "Correct Password.". Can you help me on this one?</p>
  
  <pre><code>Public cn As ADODB.Connection
  Public rs As ADODB.Recordset
  
  Sub LogIn()
  
  Dim cn As Object
  Dim rs As Object
  Dim strSql As String
  Dim DBPath As String
  Dim userId As String
  
  If Frm_UserPW.TxtBox_Password.Text = Empty Then
      MsgBox "Please type your password."
  Else
      DBPath = Range("I2").Value
      Set cn = New ADODB.Connection
  
          cn.Provider = "Microsoft.ACE.OLEDB.12.0"
          cn.Properties("Data Source") = DBPath
          cn.Properties("Jet OLEDB:Database Password") = "db12345"
          cn.Open
  
          userId = Range("C3").Value
  
          'Open a recordset
          Set rs = New ADODB.Recordset
              'rs.Open "Inbox", cn, adOpenKeyset, adLockOptimistic, adCmdTable
  
              strSql = "SELECT * FROM ApplePassword WHERE AgentName=""" &amp; userId &amp; """ AND Passwords =""" &amp; Frm_UserPW.TxtBox_Password.Text &amp; """"
          Set rs = cn.Execute(strSql)
  
              MsgBox "Correct Passsword."
              Frm_UserPW.Hide
              Main.Show
  
              'clear memory
              rs.Close
          Set rs = Nothing
          cn.Close
      Set cn = Nothing
  
  End If
  
  End Sub
  </code></pre>