Help with expression builder and IF Statements

  • Thread starter Thread starter Mike Fellows
  • Start date Start date
M

Mike Fellows

Im not really a big user of MS Access so please bear with me

I have a field which contains a numerical value (ColumnX)

In a new column in the query i need to take the value of ColumnX and if the
value is less than 1000
i need to put 30% of ColumnX into the new column
if its greater than 1000 and less than 2000
i need to put 40% of ColumnX into the new column
anc finally if its greater than 2000
i need to put 50% of ColumnX into the new column

i.e.

if columnX <=1000 then
newColumn = ColumnX*0.3
else if ColumnX >1000 and <= 2000 then
newColumn = ColumnX*0.4
else if ColumnX >2000 then
newColumn = ColumnX*0.5
endif

I have no idea how to do the above in a query, Ive looked about on the web
and I am unable to find anything to do with If statements
for Querys if anyone could help with this it would be greatly appreciated

Mike Fellows
 
Put your query into Design Mode thne put the following in
the nest available field column

IIf(ColumnX < 1000,ColumnX * 0.3, IIf(ColumnX < 2000,
ColumnX * 0.4, ColumnX * 0.5))

Hope This Helps
Gerald Stanley MCSD
 
Great help thanks - worked a treat


Gerald Stanley said:
Put your query into Design Mode thne put the following in
the nest available field column

IIf(ColumnX < 1000,ColumnX * 0.3, IIf(ColumnX < 2000,
ColumnX * 0.4, ColumnX * 0.5))

Hope This Helps
Gerald Stanley MCSD
 
Back
Top