Cannot login to a MS Access database Below is some VBA code to authorize users to login into an MS Access database. I am trying to fix this code and I don’t understand what is the issue in this code snippet.
Private Sub cmdLogin_Click()
Dim lngUserID As Long
    lngUserID = Nz(DLookup(&quot;UserID&quot;, _
    &quot;tblUser&quot;, &quot;username = '&quot; _
    &amp; Me!cbousername _
    &amp; &quot;' AND Password = '&quot; _
    &amp; Me!txtPassword &amp; &quot;'&quot;), 0)
    If lngUserID = 0 Then
        MsgBox &quot;Username and/or password are incorrect.&quot;
        Me!txtPassword.SetFocus
    Else
        MsgBox &quot;Registration successful!&quot;
        OptionSetting &quot;CurrentUserID&quot;, CStr(lngUserID)
        DoCmd.Close acForm, Me.Name
        DoCmd.OpenForm &quot;Homepage&quot;
    End If
      SetWebControlAsIE9
    ChangeWebControlFeature
END SUB

The debugger in the VBE shows the following code highlighed in yellow. Can someone help me to understand what the issue is?
lngUserID = Nz(DLookup(&quot;UserID&quot;, _
    &quot;tblUser&quot;, &quot;username = '&quot; _
    &amp; Me!cbousername _
    &amp; &quot;' AND Password = '&quot; _
    &amp; Me!txtPassword &amp; &quot;'&quot;), 0)
Instead of looking for matching username and password from the table, I would suggest you to use login system explained in this link. You just need to import forms and code from demo database from the link into your DB. You'll also get password change form and password reset option. I've use the same approach in my project. I also adopted (recommend you to do too) storing encrypted password approach to prevent user password in case the DB is compromised. If you need any help in that regard too, I'll be happy to help.