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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iif...then comparision giving baffling results

Status
Not open for further replies.
Mar 26, 2001
17
US
I'm working on a database of products with inventory tracking. I'm using a form to list all products with the Quantity On Hand (QOH), which is a number. What I'm trying to do is if a product's QOH is below a certain value, display the word "Low."

The way I'm doing this is with a Text Box with the following in the control source:

=IIf(([QOH]<[Forms]![MyFormName]![SetFlagLow]),&quot;Low&quot;,&quot;&quot;)

[QOH]: is the Quantity on Hand (data derived from a query)
[Forms]![Form]![SetFlagLow]: the value (entered by user in the &quot;parent&quot; form)


This expression is not evaulating correcting. No error message, but the result is displaying &quot;Low&quot; when the QOH is clearly greater than the value the user entered in for the flag.

However, the expression works perfectly if the flag is statically set as in the following expression:

=IIf(([QOH]<5),Low&quot;,&quot;&quot;)

I could just statically set the value, but I need to have the user be able to enter the value that they need.

Anyone know what is maybe wrong with my expression?

Thanks in advance.
 
Hello snoopy6129,
It sounds like you need to explicitly type-cast the value [Forms]![MyFormName]![SetFlagLow]. In english :), this means that you should use the following instead:
Code:
=IIf([QOH]<CLng([Forms]![MyFormName]![SetFlagLow]),&quot;Low&quot;,&quot;&quot;)
Let me know if that works. Robert
•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•
Professional, affordable, Access database solutions and assistance °•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°
 
This is just an idea,
but maybe u could make sure and put the

Cint([Forms]![MyFormName]![SetFlagLow])

just to ensure that it is reading it correctly as a number.

Other than that possibility , your code (to me) looks accurate.


Jeremy
WZ
 
Thank you SoloDroid and WhiteZiggy. Your tips worked out perfectly. That was all that was need for me to get my expression working. Thanks again.

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top