If (DLookup("[userID]", "tblUserSecurity_Sec", "[userID]='" & Me.txtUserID.Value & "' And [answer1]='" & Me.answer.Value & "'")) Then
txtuserid = userid from tblanswers that will match userID in tblUserSecurity_Sec
answer1 in tblanswers should match answer (Unbound) from frmquestionaire
answer should match answer1
AfterUpdateEvent fires from answer field on frmquestionaire
Cant display image? Dont know how to get it in?
Error 2471 The expression you entered as a query parameter produced this error. [answer] in procedure answer_AfterUpdate of VBA Document From_frmquestionaire
Error2471
-
- Administrator
- Posts: 78574
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Error2471
See Tip: adding an attachment'
You use DLookup but don't compare the result to anything. Perhaps you want
If IsNull(DLookup("[userID]", "tblUserSecurity_Sec", "[userID]='" & Me.txtUserID.Value & "' And [answer1]='" & Me.answer.Value & "'")) Then
or
If Not IsNull(DLookup("[userID]", "tblUserSecurity_Sec", "[userID]='" & Me.txtUserID.Value & "' And [answer1]='" & Me.answer.Value & "'")) Then
You use DLookup but don't compare the result to anything. Perhaps you want
If IsNull(DLookup("[userID]", "tblUserSecurity_Sec", "[userID]='" & Me.txtUserID.Value & "' And [answer1]='" & Me.answer.Value & "'")) Then
or
If Not IsNull(DLookup("[userID]", "tblUserSecurity_Sec", "[userID]='" & Me.txtUserID.Value & "' And [answer1]='" & Me.answer.Value & "'")) Then
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Error2471
Many thanks, I will test and get back tp you.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Error2471
Hth
You do not have the required permissions to view the files attached to this post.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Error2471
No luck, same error msg about answer or answer1 ???
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Error2471
Code: Select all
Private Sub youranswer_AfterUpdate()
'Check to see if answers match.
If Me.youranswer = Me.answer1 Then 'They know the correct answer.
DoCmd.Close acForm, "frmquestionaire"
DoCmd.Close acForm, "frmreset"
DoCmd.OpenForm "frmLogin"
Else
If Not Me.youranswer = Me.answer1 Then 'They dont know the correct answer.
Me.PWChk.Value = Me.PWChk.Value + 1 'Give them 3 tries for the correct answer.
If Me.PWChk.Value > 3 Then
MsgBox "You may not make more than three answer attempts.", vbCritical + vbOKOnly, "No Hacking!"
MsgBox "The answer you entered is not incorrect." & vbCrLf & _
"Please enter the correct answer or contact your Application " & _
"Administrator.", vbOKOnly, "Answer for " & Me.youranswer.Value & " Incorrect"
DoCmd.Close acForm, "frmquestionaire"
DoCmd.Close acForm, "frmreset"
DoCmd.OpenForm "frmLogin"
End If
End If
End If
Exit Sub
End Sub
-
- Administrator
- Posts: 78574
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands