Adding Null fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdminCyn
    New Member
    • Apr 2010
    • 4

    Adding Null fields

    I am trying to create a report to simulate an invoice. I have created a Select query to join all the tables/fields into one. That is working all good. I have set the Format to be 0;0;0;0 so that if it is a null field it prints a "0" instead. My issue is when there is a null value in a list of five number I want to total, I get back another null value; here is what my report looks like




    How do I tell it to ignore the null value fields and add the ones with values?
    Last edited by AdminCyn; Apr 20 '10, 10:58 PM. Reason: adding question
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by AdminCyn
    I am trying to create a report to simulate an invoice. I have created a Select query to join all the tables/fields into one. That is working all good. I have set the Format to be 0;0;0;0 so that if it is a null field it prints a "0" instead. My issue is when there is a null value in a list of five number I want to total, I get back another null value; here is what my report looks like




    How do I tell it to ignore the null value fields and add the ones with values?
    If any part of an Expression is NULL, than the entire Expression will evaluate to NULL. Put differently, NULLs will propagate through Expressions. You can use the Nz() Function to return a 0 should a Field be NULL, as in:
    Nz(Field1) + Nz(Field2) + Nz(Field3) + Nz(Field4)...
    That being said:
    Code:
    Debug.Print Nz(75) + Nz(NULL) + Nz(25) + Nz(NULL)
    will return
    Code:
    100

    Comment

    • AdminCyn
      New Member
      • Apr 2010
      • 4

      #3
      Brilliant! Works Perfectly :O)

      Comment

      Working...