IF statements

  • Thread starter Thread starter RMASSEY2
  • Start date Start date
R

RMASSEY2

I am trying to figure out how best to use the if statement - whether in
a query or in the report. (I would like to use it in the report). I
have a field "missed oppt" with a percent 10% and I want to do an if
statement - IIF([missed oppt]<13 then score =1) Score is an unbound
field on my report. I was putting the IF statement "on open" for the
report, but it doesn't seem to work. Any suggestions - can the IF
statement work on a report?
 
Put a field on your report and in it put =IIF([missed oppt]<13, 1,
(Value when [Missed Oppt] >= 13). To use IIF, you must have a value
for when your condition is true and a value for when your condition is
false. You can nest IIF statements if needed.
 
thank you - that worked - now one more question - if I want to nest IIF
statements -
woule it be like =IIF([missed oppt]<13,1)IIF([missed oppt]<15,0)...?

Jeff said:
Put a field on your report and in it put =IIF([missed oppt]<13, 1,
(Value when [Missed Oppt] >= 13). To use IIF, you must have a value
for when your condition is true and a value for when your condition is
false. You can nest IIF statements if needed.

I am trying to figure out how best to use the if statement - whether in
a query or in the report. (I would like to use it in the report). I
have a field "missed oppt" with a percent 10% and I want to do an if
statement - IIF([missed oppt]<13 then score =1) Score is an unbound
field on my report. I was putting the IF statement "on open" for the
report, but it doesn't seem to work. Any suggestions - can the IF
statement work on a report?
 
I recommend against nesting IIf() statements more than 2 deep. If you find
yourself nesting IIf()s, consider:
-create a small lookup table of ranges and values
-create a user-defined function
You should not be maintaining business logic/rules in expressions in
queries.

--
Duane Hookom
MS Access MVP

thank you - that worked - now one more question - if I want to nest IIF
statements -
woule it be like =IIF([missed oppt]<13,1)IIF([missed oppt]<15,0)...?

Jeff said:
Put a field on your report and in it put =IIF([missed oppt]<13, 1,
(Value when [Missed Oppt] >= 13). To use IIF, you must have a value
for when your condition is true and a value for when your condition is
false. You can nest IIF statements if needed.

I am trying to figure out how best to use the if statement - whether in
a query or in the report. (I would like to use it in the report). I
have a field "missed oppt" with a percent 10% and I want to do an if
statement - IIF([missed oppt]<13 then score =1) Score is an unbound
field on my report. I was putting the IF statement "on open" for the
report, but it doesn't seem to work. Any suggestions - can the IF
statement work on a report?
 
Not quite.
=IIF([missed oppt]<13,1, IIF([missed oppt]<15,0, Value when [Missed
Oppt] >= 15)). I agree that you probably shouldn't do more than 2
nested IIFs. Creating a function would be more efficient.


thank you - that worked - now one more question - if I want to nest IIF
statements -
woule it be like =IIF([missed oppt]<13,1)IIF([missed oppt]<15,0)...?

Jeff said:
Put a field on your report and in it put =IIF([missed oppt]<13, 1,
(Value when [Missed Oppt] >= 13). To use IIF, you must have a value
for when your condition is true and a value for when your condition is
false. You can nest IIF statements if needed.

I am trying to figure out how best to use the if statement - whether in
a query or in the report. (I would like to use it in the report). I
have a field "missed oppt" with a percent 10% and I want to do an if
statement - IIF([missed oppt]<13 then score =1) Score is an unbound
field on my report. I was putting the IF statement "on open" for the
report, but it doesn't seem to work. Any suggestions - can the IF
statement work on a report?
 
Back
Top