help with if statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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)
 
Dear DB:

I think what you may want is:

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

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)
 
One way
IIF([TorN] = "N", [median] ,[median] * 1.2)

Or
[median] * IIF([TorN] = "N", 1 ,1.2)
 
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)
 

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

Back
Top