#Error in Textbox

  • Thread starter Thread starter Spidey3721
  • Start date Start date
S

Spidey3721

I have a textbox that uses the selection of a Listbox on the same form as
part of it's control source (inside of a DLookup statement).

How can I prevent the Textbox from showing "#Error", if there is nothing
selected in the Listbox yet ? I would like it to be blank.

I am assuming maybe an IIF statement wrapped around the DLookup ?
 
Nz() should do the trick:

=DLookup("SomeField", "SomeTable",
"AnotherField = " & Nz([MyListbox], 0))

This prevents the case where the 3rd argument resolves to just:
AnotherField =
when the list box is null.
 
Back
Top