Substituting null values with a zero on a report?

chuckles1066

Banned
Joined
Dec 20, 2004
Messages
372
How?

I have a query which provides the data for a report.

A lot of the fields in the query don't have data and I'd like those reported as zero rather than appearing as empty on my report.

For example (just to clarify), my query returns all employee activity during a month.....hours worked, sick hours, holiday hours, training hours etc etc.

Now obviously, not all those fields have a value (an employee may not have taken holiday last month for example).....I just need that to show on my report as 0.00.

I tried messing about with an =IIf statement in the control source part but Access protested about a circular reference.

Any guidance much appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
In your query, use the NZ function in a calculated expression, which tells it what to return in the event of a null value, i.e.

My_Hours_Worked: NZ([Hours_Worked],0)

Then just return this calculated value on your report.
 
Upvote 0
Your welcome.

One caveat. By default, the NZ function returns a text value. This might not be a big deal if you are just reporting on it. But if you need to format it in some number format, or if you need to use it in computations, you may need it to be numeric.

You can easily coerce it to be a number by adding zero to it, i.e.

My_Hours_Worked: NZ([Hours_Worked],0)+0
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top