Question : Access 2007Nz and nvl functions don't work on report field with a Sum if no records are present

I have a subreport on a report that queries some records and then has a standard sum field at the bottom of the subreport.  The sum field data is:  =sum([extendedprice]).  Field source is currency format.

When there are no records present, the Sum field data is blank or null or zero length.  Not sure which.  I have tried tons of variations of Nz and Nvl functions to get a zero to show up in that field.  I need it to be zero so that other calculations on the report can continue without being an "#error" field.

I have tried all answers I can find on experts exchange, nothing is working.  I have tried IIf statements that test for Null or zero length "", but nothing I do will return a "0" in that field.  There has got to be a way to do this when there are no records presend in the "Details" section of the report.  Obviously all symptoms go away when there are any records at all, but I need it to work with absolutely no data.

Answer : Access 2007Nz and nvl functions don't work on report field with a Sum if no records are present

Say the subreport is in a subreport object called subDetail, and the report contained therein calculates the sum of an amount as =Sum(amt) in the report footer control named txtSumAmt.

This works fine when there is data. However, when there is none, the entire subreport disappears, and there simply is no control called txtSumAmount to read from...

You actually need to test for the presence of data, and the main report can use an expression like this to do so:

   =IIf(subDetails.Report.HasData,subDetails!txtSumAmt,0)

I hope this helps!
(°v°)
Random Solutions  
 
programming4us programming4us