Calculation

F

fipp

I have a textbox that calculatas on an afterupdate event. I understand all of
that it is equal to [fpos]+[net]. What I am trying to do is if my result
returns a value >50 then I want to Subtract that value by 50 and multiply it
by -1
 
J

John W. Vinson

I have a textbox that calculatas on an afterupdate event. I understand all of
that it is equal to [fpos]+[net]. What I am trying to do is if my result
returns a value >50 then I want to Subtract that value by 50 and multiply it
by -1

IIF([fpos] + [net]) > 50,-([fpos] + [net] -50), [fpos] + [net])
 
F

fredg

I have a textbox that calculatas on an afterupdate event. I understand all of
that it is equal to [fpos]+[net]. What I am trying to do is if my result
returns a value >50 then I want to Subtract that value by 50 and multiply it
by -1

Is this what you want?

=IIf(Nz([fpos])+Nz([Net])>50,((Nz([fpos])+Nz([Net]))-50)*-1,Nz([fpos])+Nz([Net]))
 
F

fipp

That is exactly what I was trying to do and it works. I have now added the if
unit which is a text variable is = to "KOR" Or "PR" for some reason it does
not work. I started without using quotes and it didn't recognize when the
value was = PR or KOR. I then added the quotes and it now debugs it?


If Me!unit = "KOR" Or "PR" And Abs(Me!ydl) + Me!net > 50 Then
Me!startingpoint = -(Abs(Me!ydl) + Me!net - 50)
 
F

fipp

it works without the Or in the if part of the statement. Is it not possible
to put an Or in there?
 
F

fipp

I figured it out. Thanks for your help.

If Me!unit = "KOR" Or Me!unit= "PR" And Abs(Me!ydl) + Me!net > 50 Then
Me!startingpoint = -(Abs(Me!ydl) + Me!net - 50)
 
J

John W. Vinson

I figured it out. Thanks for your help.

If Me!unit = "KOR" Or Me!unit= "PR" And Abs(Me!ydl) + Me!net > 50 Then
Me!startingpoint = -(Abs(Me!ydl) + Me!net - 50)

That's still not going to work the way you want. The AND operator is
"stronger" than OR so it will evaluate the following two conditions:

Me!unit = "KOR"
Me!unit= "PR" And Abs(Me!ydl) + Me!net > 50

and if either one of them is TRUE it will set startingpoint to your
expression.

You'll need to use parentheses:

If (Me!unit = "KOR" Or Me!unit= "PR") And Abs(Me!ydl) + Me!net > 50 Then
 

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

Top