help with if statement

D

dlb1228

how do i do this in a query if my field equals N then take another field
and multiply by 1 else if field is a T then multiply by 1.2

i thought it would be something like this

IIF([TorN] = N, [median] * 1, 1.2)
 
T

Tom Ellison

Dear DB:

I think what you may want is:

IIf([TorN] = "N", 1, 1.2) * [median]

Tom Ellison
 
T

Tom Ellison

Dear Duane:

That works, too!

Tom Ellison


Duane Hookom said:
Try
CalcColumn: [median] * IIf([TorN] = "N", 1, 1.2)

--
Duane Hookom
MS Access MVP
--

dlb1228 said:
how do i do this in a query if my field equals N then take another
field
and multiply by 1 else if field is a T then multiply by 1.2

i thought it would be something like this

IIF([TorN] = N, [median] * 1, 1.2)
 
O

Ofer

One way
IIF([TorN] = "N", [median] ,[median] * 1.2)

Or
[median] * IIF([TorN] = "N", 1 ,1.2)
 
J

Jerry Whittle

What is the datatype for [TorN] ? If it is Text, you need quotation marks
around the N like "N".

If it's a True/False field, use something like this:

IIF([TorN] = 0, [median], 1.2)

Also the above only works on "N" or 0. If you have any other values besides
N and T, you'll either need to nest some IIf statements or create a Case
statement in a module.

Hummm.. What do you want to multiply by 1.2? TorN or median? Also there is
no need to multiply anything by 1.

IIF([TorN] = 0, [median] , [median] *1.2)
 
Top