If VEH_CODE is a Text type field, try:
CL: IIf([VEH_YEAR] = 2003,
DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = """ & [VEH_CODE] & """"),
"do something else")
If it is a Number type field, you need to consider the case where VEH_CODE
is Null, and therefore the 3rd argument would equate to just:
[Vehicle_Code] =
To prevent that:
CL: IIf([VEH_YEAR] = 2003,
DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = " Nz([VEH_CODE], 0)),
"do something else")
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Wei" <(E-Mail Removed)> wrote in message
news:0ab701c3d530$3af3ab60$(E-Mail Removed)...
> The following expression returns "#Error", can anyone
> please tell me why?
>
> CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
> mce","[Vehicle_Code]=" & [VEH_CODE]),"do something else")
>
> "vrg-mce" is a table that contains fields like
> Vehicle_Code, 2003CL, etc.
>
> I think the problem is in here:"[Vehicle_Code]=" &
> [VEH_CODE]. But I don't know how to fix it.
>
> Thanks for any help.
>
> Wei