Calculated control with IF

  • Thread starter Thread starter Lasse T
  • Start date Start date
L

Lasse T

Hello !!

I have a form with a calculated field named "tot" in the sub form looking
like this: =Sum([Relation]!Radsumma)
I also have another field named "kundkat" in the parent form wich can have
one of three values 1, 2, 3.

This is what i want to do.

If the field "kundkat" = 1 or 2 then the field tot =
Sum([Relation]!Radsumma)
If the field "kundkat" = 3 then the field "tot" = Sum([Relation]!Radsumma)
rounded down to nearest 5.

Hope someone can help me with this.

Thanks in advance

Lasse T
--------------
 
Lasse,

Try this...
=IIf([kundkat]=3,(Sum([Relation].Radsumma)\5)*5,Sum([Relation].Radsumma))
 
Hello and thank you for your ansver.

I tried this but can not get it to work. I get an error saying that a
paranthese or something is missing. Could you pleas check it again? I tried
to change it in all the ways I could come up with.


Lasse T
--------------

Steve Schapel said:
Lasse,

Try this...
=IIf([kundkat]=3,(Sum([Relation].Radsumma)\5)*5,Sum([Relation].Radsumma))

--
Steve Schapel, Microsoft Access MVP


Lasse said:
Hello !!

I have a form with a calculated field named "tot" in the sub form looking
like this: =Sum([Relation]!Radsumma)
I also have another field named "kundkat" in the parent form wich can have
one of three values 1, 2, 3.

This is what i want to do.

If the field "kundkat" = 1 or 2 then the field tot =
Sum([Relation]!Radsumma)
If the field "kundkat" = 3 then the field "tot" = Sum([Relation]!Radsumma)
rounded down to nearest 5.

Hope someone can help me with this.

Thanks in advance

Lasse T
 
Lasse,

Sorry, at the moment, I can't see any error with the syntax of the
expression, but I'll check it again later. :-)
 
I tried this but can not get it to work. I get an error saying that a
paranthese or something is missing. Could you pleas check it again? I tried
to change it in all the ways I could come up with.

Just a speculation: the Swedish language setting might require
semicolons rather than commas. Does

=IIf([kundkat]=3; (Sum([Relation].Radsumma)\5)*5;
Sum([Relation].Radsumma))
 
John Vinson said:
I tried this but can not get it to work. I get an error saying that a
paranthese or something is missing. Could you pleas check it again? I tried
to change it in all the ways I could come up with.

Just a speculation: the Swedish language setting might require
semicolons rather than commas. Does

=IIf([kundkat]=3; (Sum([Relation].Radsumma)\5)*5;
Sum([Relation].Radsumma))

YESSS.... That worked. Thank you wery much.

Lasse T
-----------
 
Back
Top