Reputation: 251
The expression:
=IIf(([cbo1]IS NOT NULL),DLookUp("[Thing1]","[tbl1]","[cbo1]= " & [Forms]![frm1]![cbo1]), "")
returns "#Error" when I try to use it to populate a text box based on the value of a combo box. The values in the combo box are all words, so setting
=IIF([cbo1]>0
in the first part creates a different error. I have this expression on a different part of the form and it works fine for numerical values.
=IIf(([txt1]>0),DLookUp("[thing1]","[tbl11]","[Thing2]= " & [Forms]![Frm1]![txt1]),"")
What am I missing on the one dealing with text?
Upvotes: 1
Views: 114
Reputation: 97101
IS NOT NULL
is supported in Access SQL, but not in VBA expressions. Use IsNull()
.
=IIf(Not IsNull([cbo1]), DLookUp("[Thing1]", "tbl1", "[cbo1]=" & [cbo1]), "")
Note the DLookUp
expression requires that tbl1 includes a numeric field named cbo1, the same as your combo box name. That could be correct, but it looks suspicious to me. Double-check that field name if you get another error.
Upvotes: 2