Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple calculation

Status
Not open for further replies.

owizard

Programmer
Feb 19, 2002
13
GB
Hi,

I am really sorry for asking such a simple question. I need to calculate the total of 5 fields in an unbound text box with an expression.
c1, c2, c3, c4, c5

My expression in the control source is =[c1]+[c2]+[c3]+[c4]+[c5]
I want the text box to have the value of C1, if that is the only value present (the other four fields being blank).
However, I get a value in the text box only if I enter all five values. Kindly suggest any possible solution. Thanks a lot.
 
This will work for Access 2000+ and assumes that C1 - C5 are nembers:

=nz([c1])+nz([c2])+nz([c3])+nz([c4])+nz([c5])

Bill
 
Use the Nz function to return a zero if the field is null. Somehting like this:

=Nz([C1])+Nz([C2])+Nz([c3])+Nz([C4])+Nz([C5])
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top