Getting rid of #Errors

G

grep

I have several calculated fields that rely on lookups of on data that
may not yet exist. (This occurs most often on New records). Often the
result of the calculation is an #Error condition, which it says right in
the field. I'd like to get rid of the #Error message. Just being blank
would be better. How?

TIA

grep
 
W

Wayne Morgan

You can use an IIf or Nz function to get rid of the errors.

Example:
=Nz([Field1])+Nz([Field2])
or
=IIf(IsDate([Field1]), [Field1], "")
or
=IIf(IsNull([Field1]), "No Entry", [Field1])
or
=Nz([Field1], "No Entry")

The last two are equivalent. To give more specific examples, I would have to
see your equations and know what data types the fields are.
 
G

grep

I'll see if I can find a useful direct example that wouldn't be too
convoluted - hell, my entire coding might be - but here's specifically
where I'm trying to go:

The field is set to: dlookup("Subtotal1", "tblAllWidgets", "[OrderID]= "
& OrderID) + nz(Subtotal2, 0)

Now, the problem is that until I've actually told the current record
what OrderID it's associated with (i.e. while it's still in NewRecord
state), "[OrderID]= " & OrderID produces an error condition because
Me.OrderID = Null. So the entire lookup can't happen. Hence #Error.

That's what I'm trying to relieve. I'd prefer it to be blank.

grep
 
W

Wayne Morgan

See if this will work for you.

=IIf(IsNull([OrderID]), "", DLookup("Subtotal1", "tblAllWidgets",
"[OrderID]= " & OrderID) + nz(Subtotal2, 0))

If the "" gives a data type mismatch, try Null instead.
 
G

grep

Wayne said:
See if this will work for you.

=IIf(IsNull([OrderID]), "", DLookup("Subtotal1", "tblAllWidgets",
"[OrderID]= " & OrderID) + nz(Subtotal2, 0))

If the "" gives a data type mismatch, try Null instead.

Hey Wayne - as soon as I looked at your suggestion, I knew it would
work. It did. The way I was looking at it was so much more complicated.
Thanks much!!

grep
 

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