Calculate Total based on Null Field

54 Views Asked by At

I have a database that creates Invoices based on Work Orders, by a "WOrderID". I have a section that calculates Subtotal - Payments = Amount Due. The payments are generated from another table which has the WOrderID and the Payment Amount.

I want the field to generate $0.00 if there is no WOrderID in Payments matching the Work Order I am Invoicing, because it means no payments have been made for that Work Order.

I have the following code in the Payments field, but it gives me a "########" error, instead of returning 0.00 and allowing the Amount Due to subtract Subtotal and Payments to get a value:

=IIf(IsNull(DLookUp("[Amount]","Payment","[WOrderID] = '" & [txtWOrderID] & "'")),0,DSum("[Amount]","Payment","[WOrderID] = '" & [txtWOrderID] & "'"))
1

There are 1 best solutions below

0
On

Thanks... figured it out that I had a conflicting format on the field causing the error.