kennykee said:
What's Wrong?
Error Message==>you canceled the Previous Action/Event
Dim Strfilter as String
StrFilter = ((Me!ProductCode = Query!CodesAndProducts!ProductCodes)
And (Me!WoodTypes = Query!CodesAndProducts!WoodTypes))
Me!HardwarePrice = DLookup ("HardwarePrice", "CodesAndProducts",
StrFilter)
Thanks
Kennykee
What on earth is StrFilter supposed to be? You are not setting it to a
string, but rather the result of evaluating this condition:
((Me!ProductCode = Query!CodesAndProducts!ProductCodes)
And (Me!WoodTypes = Query!CodesAndProducts!WoodTypes))
What are you trying to accomplish with the "Query!" qualifier? It's not
a proper qualifier. Are you trying to look up the HardwarePrice from
the record in CodesAndProducts that has the same ProductCodes and
WoodTypes as are currently on the form where this code is running? If
so, this is how to do it:
StrFilter = _
"ProductCodes=" & Me!ProductCode & _
" And WoodTypes=" & Me!WoodTypes
Me!HardwarePrice = _
DLookup ("HardwarePrice", "CodesAndProducts", StrFilter)
That assumes that the names you gave were correct -- note that you said
"CodesAndProducts!ProductCodes", but said "Me!ProductCode" -- and that
these are both numeric fields. If they're text, you need to add some
quotes to the filter string:
StrFilter = _
"ProductCodes='" & Me!ProductCode & _
"' And WoodTypes='" & Me!WoodTypes & "'"
All this, of course, is just guessing at what you're trying to do.