Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF Statement Problem 1

Status
Not open for further replies.

iceman30

Technical User
Nov 4, 2003
4
US
I have the following IIF statment in a report drawing its data from a query:

IIf([totalsolidsmin],IIf([totalsolidsmax],[totalsolidsmin] & " - " & [totalsolidsmax],[totalsolidsmin] & " minimum"),IIf([totalsolidsmax],[totalsolidsmax] & " maximum",""))

Depending on the presence or absence of totalsoldismin and totalsolidsmax there can be one of four outcomes (assume totalsolidsmin = 62.00 and totalsolidsmax = 63.00):
62.00 - 63.00
62.00 minimum
63.00 maximum
""
Everything works great unless the numbers drop below 0.5, then the outcome is always "".

Any suggestions or alternatives would be appreciated.
Thanks.

 
When you the "the numbers drop below 0.5", which numbers are you talking about. The min, the max, or both, since only one is used at a time in a conditional?

In any event, I think what may be happening is that in your first IIf conditional [totalsolidsmin] is being evaluated as a True/False, and as such, is being coerced into an integer which when you drop below 0.5 becomes 0 or False. And is quite possible the same is happening to [totalsolidsmax] in the 2nd and 3rd conditionals.



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Both the min and/or the max can drop below 0.5...

If it is being coerced into an integer, how do I get the report to recognize it as a single and treat it as such???
 
CajunCenturion is very perceptive and deserves a star.
To fix the expression, try:
IIf([totalsolidsmin]<>0,IIf([totalsolidsmax]<>0,[totalsolidsmin] & &quot; - &quot; & [totalsolidsmax],[totalsolidsmin] & &quot; minimum&quot;),IIf([totalsolidsmax],[totalsolidsmax] & &quot; maximum&quot;,&quot;&quot;))
If there is a possibility of Null values, you may need to substitute
Nz([TotalSolidMin],0)<>0 etc
BTW: You should consider using mixed case field/variable names since they are much easier to discern.


Duane
MS Access MVP
 
Depending on the field types, you might want to consider using a Val function
IIf(Val([totalsolidsmin])<>0,

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Simple solution. Thank you CajunCenturion and dhookom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top