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("UserID", _
"tblUser", "username = '" _
& Me!cbousername _
& "' AND Password = '" _
& Me!txtPassword & "'"), 0)
If lngUserID = 0 Then
MsgBox "Username and/or password are incorrect."
Me!txtPassword.SetFocus
Else
MsgBox "Registration successful!"
OptionSetting "CurrentUserID", CStr(lngUserID)
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Homepage"
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("UserID", _
"tblUser", "username = '" _
& Me!cbousername _
& "' AND Password = '" _
& Me!txtPassword & "'"), 0)