#Error in Textbox

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 ?
 
A

Allen Browne

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.
 

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