Solved Null Value

Seph

Member
Local time
Today, 23:03
Joined
Jul 12, 2022
Messages
72
Good day everyone.

Please could you lend a Machete to my intellectual bush.

I have an Invoice form that calculates values from 3 tables (Master Fields Linked by Primary Key).

However, whenever a single table (Cost in this case) has no records. The Calculation fields stop working.

1664181336930.png



I've tried adding a NZ function to the Cost Total Sum Text Field (No Success):

1664182227354.png


I've Tried adding a NZ function to the Cost Total Field in the Query that the form is sourced to (No Success):

1664181723811.png


I suspect the issue here is that due to the fact that there is no records captured for Costs linked to the Primary Key, Access can't populate any information.
Which is perfectly sensible. However, how can I get it to replace vacant records with 0 so the formula's can continue to function as there won't always be Costs included in all jobs.

Appreciate any ideas.

Thanks
 

Attachments

  • 1664181577065.png
    1664181577065.png
    3.9 KB · Views: 117
use this Expression on the textbox on the Footer section:

=Nz(Sum([CostTotal]), 0)
 
Possibly need to left join to your costs table?
 
use this Expression on the textbox on the Footer section:

=Nz(Sum([CostTotal]), 0)
You sir are a legend.

Spent hours trying to figure it out before visiting here.

Really appreciate your assistance!
 
=Sum(YourField) ---- ignores null values so you don't need the Nz()

However,

=Sum(Fld1 + fld2) --- will REQUIRE the Nz() if either field might be null
=Sum(Nz(fld1,0) + Nz(fld2,0))

If you want the final result to show 0 rather than blank, that's when you put the Nz() around the whole expression.

=Nz(Sum(YourField))
=Nz(Sum(Nz(fld1,0) + Nz(fld2,0)),0)

In summary, the aggregating functions ignore nulls BUT, for other arithmetic, you need them.
 

Users who are viewing this thread

Back
Top Bottom