By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

MS Access Log in through security question and answer

P: 12
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.
Nov 26 '16 #1
Share this Question
Share on Google+
1 Reply


PhilOfWalton
Expert 100+
P: 1,430
In debug mode, what value are you getting for Me.cmbSecQ. Are you getting a number or are you getting the question?
Check what value you get from Me.cmbSecQ.Column(1) or check to see which is the bound column.

Incidentally , I would not use the word .Value in your expression. It should not be neccessary.

Phil
Nov 27 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.