Field query expression

D

Dave

I mistakenly posted this in the DAO VBA area.

Maybe someone here can help:
My Field query expression is:
Expr1: IIf(IsNull((SELECT Sum(Kgs) AS SumOfKgs FROM
DailyProductShipments;)),0,(SELECT Sum(Kgs) AS SumOfKgs
FROM DailyProductShipments;))

The reason I use IsNull is because I need this query to
return a "zero" if it finds no record (shipments for the
time period defined in DailyProductShipments). This query
properly returns a value for Sum(Kgs) as long as there are
one or more records. However, it returns no value if there
are no records. How can I get it to return a zero or is
there a beter way to do this?

Thanks in advance,
Dave
 
F

fredg

I mistakenly posted this in the DAO VBA area.

Maybe someone here can help:
My Field query expression is:
Expr1: IIf(IsNull((SELECT Sum(Kgs) AS SumOfKgs FROM
DailyProductShipments;)),0,(SELECT Sum(Kgs) AS SumOfKgs
FROM DailyProductShipments;))

The reason I use IsNull is because I need this query to
return a "zero" if it finds no record (shipments for the
time period defined in DailyProductShipments). This query
properly returns a value for Sum(Kgs) as long as there are
one or more records. However, it returns no value if there
are no records. How can I get it to return a zero or is
there a beter way to do this?

Thanks in advance,
Dave

I'm not sure if this will work in this instance, but give it a try:

Expr1: Nz((SELECT Sum(Kgs) AS SumOfKgs FROM
DailyProductShipments;),0)
 

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