Microsoft Access: Replacing null with a zero.

If you use a field that contains a null in a mathematical expression, you might get unexpected results. For example, you have a field named cost, which contains the cost of an item. You have another field named fees, which contains fees associated with the same item. When you create an expression to calculate the total cost (cost + fees) you will not see the total cost for any item where the fees are null (unknown). As I explained in my previous post, Microsoft Access does not know what the value is in a null field, therefore it cannot complete the calculation. In this case, you might want to turn the null into a zero allowing you to view the items cost without the fees. The Nz function can change a null to a value. To change any record where the fees where a null to a zero you would enter: Total Cost: Nz([fees])+[cost]. For more information on how to change the null to another value, go to http://office.microsoft.com/en-us/access/HA012288901033.aspx

Syndicate content