Getting run time error 2471

abzalali

Registered User.
Local time
Today, 15:21
Joined
Dec 12, 2012
Messages
118
Dear Expert,
Getting run time error 2471, code below:
Code:
Private Sub Quantity_AfterUpdate()
Dim strCriteria As String
Dim CusType As String

strCriteria = "[ID] = '" & Forms![frmInvoice]![CustomerType] & "'"
CusType = DLookup("[ID]", "Customer List", "strCriteria LIKE " & """" & "*Pet Store*" & """")

    If Me.Quantity > 0 Then
        If CusType > 0 Then
            Me.UnitPrice = Me.cboFish.Column(1)
        Else
            Me.UnitPrice = Me.cboFish.Column(2)
        End If
        
        Me.NetAmount = Me.[Quantity] * Me.[UnitPrice]
        
    ElseIf Me.Quantity = 0 Then
        Me.UnitPrice = 0
    Else
        Me.UnitPrice = 0
        Me.NetAmount = 0
    End If
End Sub
The expression your entered as query parameter produced this error: 'strCriteria '
error go in this line:
Code:
CusType = DLookup("[ID]", "Customer List", "strCriteria LIKE " & """" & "*Pet Store*" & """")
Please anybody help me.
 
Dear Genius,
strCriteria = "[ID] = '" & Forms![frmInvoice]![CustomerType] & "'"
CusType = DLookup("[ID]", "Customer List", "strCriteria LIKE " & """" & "*Pet Store*" & """")
Those two lines aren't well-formed. If run, the WHERE part of the DLookup() function would translate to:
Code:
ID = 'CustomerType_Value' LIKE "*Pet Store*"
As you can see that won't make much sense to the DLookup() function. So what you probably need is one of the following:
Code:
strCriteria = "[ID] = Forms![frmInvoice]![CustomerType]"
CusType = DLookup("[ID]", "[COLOR="red"][[/COLOR]Customer List[COLOR="red"]][/COLOR]", strCriteria)
Code:
CusType = DLookup("[ID]", "[COLOR="red"][[/COLOR]Customer List[COLOR="red"]][/COLOR]", "[[COLOR="Blue"]SomeField[/COLOR]] LIKE '*Pet Store*'")
 
Dear

I have Main Form with a subform
Main form contain "Customer Type"
and Subform contain "Quantity"
I just want when I enter quantity then it check Main Form Customer type LIKE "Aquarium" or not



How do I check this?
 
I just gave you two solutions. Try them both and see what you come up with. If you're still struggling ask for some guidance.
 
Yes I'm still struggling
Code:
CusType = DLookup("[ID]", "[COLOR=red][[/COLOR]Customer List[COLOR=red]][/COLOR]", "[[COLOR=Blue]SomeField[/COLOR]] LIKE '*Pet Store*'")


strCriteria = "[ID] = Forms![frmInvoice]![CustomerType]"If I set strCriteria instead of [some filed] then It will be solve,
Please help me.
 

Users who are viewing this thread

Back
Top Bottom