Math question

  • Thread starter Thread starter tomanddani via AccessMonster.com
  • Start date Start date
T

tomanddani via AccessMonster.com

Hi,
Im tring to write a expression. I want to subtract number 1 from number 2. If
number 1 is smaller than number 2 I dont want to end up with a negitive
number, in that case I want to end up with zero. If number 1 is larger than
number 2 then of course I wont have a problem. After all that is done I want
to add the result to another number.

This is what I came up with but it wont handle negitive numbers ie. [Number1]
being smaller than [Number2]

([Number1] - [Number2])+[Number3]

Thanks
Tom
 
Are you using ACCESS? Are you doing this in a query?

Assuming the answer to both questions is yes, use a calculated field like
this:

MyNum: IIf([Number1]>=[Number2],[Number1]-[Number2],0)+[Number3]
 
I want to subtract number 1 from number 2

well, first off, to subtract number1 from number2, the equation would be

number2 - number1

in that case, if number1 is smaller than number2, you'll never have a
negative number. i'm going to assume that you actually want is to subtract
number2 from number1, since that's the equation you posted; in which case,
try

IIf(Number2 > Number1, 0, Number1 - Number2) + Number3

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top