I have a table : tblEmployees having lngEmpID(autonumber), strEmpName(text), SecurityQuestion(number-look up from another table) and SecurityAnswer(text).
I am trying to create a log-in form by selecting Employee name from one combo box(cboEmployeeQ)and security question from another combo box(cmbSecQ); and putting security answer in another textbox(txtSecAns) and a command button(cmdLoginQ) to log-in.
I have written the vb code(I have taken help from another post):
Private Sub cmdLoginQ_Click()
Dim t As Variant
t = DLookup("SecurityAnswer", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployeeQ.Value)
Dim u As Variant
u = DLookup("SecurityQuestion", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployeeQ.Value)
'Close logon form and open splash screen
If Me.txtSecAns.Value = t And Me.cmbSecQ = u Then
DoCmd.OpenForm "frmSplashScreen1"
DoCmd.Close acForm, "User", acSaveNo
Else
MsgBox "Security Question and Answer Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtSecAns.SetFocus
End If
End Sub
....
But its not working- it always shows msgbox:"Security Question and Answer Invalid. Please Try Again"- as written if employee record does not match
Kindly help.