Can I use =Nz([field1],0) + Nz([field2],0) with devide in stead of plus?
Rabbie warned you against dividing by Zero, but really didn't answer your question. The answer is Yes, you can use Nz() for dividing, with a little change. The default replacement argument for Nz() is Zero, as in
Nz([field1],0)
but you can change thios argument to something else.
If, for instance, you want to use field1 as the divisor in a calculation, you need, as Rabbie said, not to have it equal to Zero, so you change the argument to
1.
Nz([field1],
1)
If field1 is Null, it'll now be replaced by
1.
If you have a number and don't want it divided by anything, you actually want it to remain the same, and any number divided by
1 remains the same!.
If field1 is Null, you want 10 divided by field1 to equal 10. So if field1 is Null,
10 / Nz([field1],
1)
then becomes
10 / 1
which equals 10, your desired results!
Note that Nz() can also be used for text values. Say, for example, you have a field in a report that holds clients (txtClient) and a field that holds agents (txtAgent). If a client doesn't have an agent assigned to them, the txtAgent field will be Null, and nothing will print under the agent field for that client. But by using
Nz([txtAgent], "
Unassigned")
if there's nothing in the txtAgent field, "
Unassigned" will now be printed instead of a blank.