DLookup w/ "and" statement

B

bill

The following piece of code is generating a "Type
Mismatch" error. What I'm not sure about is using
an "And" statement within the DLookup function (next to
last line). Does anyone see a problem here?


Dim strBeg As String, strMiddle As String, strEnd As
String, strFull As String, strOrder As String

strOrder = "[ORDER_NUMBER]=" & Me!OriginalInvoice
strBeg = "B"
strMiddle = Me!ItemCode

If Me!Size = "XL" Then
strEnd = "6"
End If

If Me!Size = "2XL" Then
strEnd = "7"
End If

If Me!Size = "3XL" Then
strEnd = "8"
End If

strFull = "[ITEM_NUMBER]='" & strBeg & strMiddle &
strEnd & "'"

Me!Price = DLookup("PRICE", "dbo_ORDER_DETAIL",
strOrder And strFull)

End Sub
 
D

Douglas J. Steele

I'm having a hard time figuring out what your code is supposed to be doing,
but I think the following should work:

Me!Price = DLookup("PRICE", "dbo_ORDER_DETAIL", strOrder & " And " &
strFull)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top