Error2471

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Error2471

Post by burrina »

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

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error2471

Post by HansV »

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
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Error2471

Post by burrina »

Many thanks, I will test and get back tp you.

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Error2471

Post by burrina »

tblUserSecurity_Sec.png
tblanswers.png
frmquestionaire.png
Here are some screenshots
Hth
You do not have the required permissions to view the files attached to this post.

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Error2471

Post by burrina »

No luck, same error msg about answer or answer1 ???

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Error2471

Post by burrina »

DemoV2.zip

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Error2471

Post by burrina »

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
Finally this works in full version.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error2471

Post by HansV »

Good to hear that.
Best wishes,
Hans