adding and subtracting fields in a table...

  • Thread starter Thread starter Brad Rosevear
  • Start date Start date
B

Brad Rosevear

I want to add the values of several fields in the same table. If I can
get the first to work then I can figure out the rest. I want to creat a
field "X" and this field will equal "A" + "B" + "C" -"D". So if A=5,
B=10, C=15 and D=20 then the default value of X will be 10. Can
somebody help me with the correct syntax?
Thankyou.
Brad
 
Hi,
That should be
a) if they are variables =A+B+C-D
b) if they are fieldnames =[A]++[C]-[D]
Marc
 
I want to add the values of several fields in the same table. If I can
get the first to work then I can figure out the rest. I want to creat a
field "X" and this field will equal "A" + "B" + "C" -"D". So if A=5,
B=10, C=15 and D=20 then the default value of X will be 10. Can
somebody help me with the correct syntax?
Thankyou.
Brad

On a form (or in a Report), add an unbound control.
Set it's control source to:
=Nz([FieldA]) + Nz([FieldB]) + Nz([FieldC]) - Nz([FieldD])

This calculated amount need not be stored in any table.
Whenever you need the result, simply repeat the above calculation.
Look up the Nz() functon in VBA help. It prevents incorrect sums in
the event one of the Fields in the calculation is Null.
 
Back
Top