Problem with Expression

lstantliff

Registered User.
Local time
Today, 18:11
Joined
Apr 28, 2006
Messages
24
:confused: Can anyone tell me what might be wrong with this expression? It is returning "-1".

=(IIf([Forms]![AnnualDialog]![Dept]=41,"Casing") Or IIf([Forms]![AnnualDialog]![Dept]=64,"Open Stock"))

A parameter (either 41 or 64) is entered on a form (AnnualDialog) and the expression above is in a text box on a form where the parameter is returned.

Thanks for your help!
 
lstantliff said:
:confused: Can anyone tell me what might be wrong with this expression? It is returning "-1".

=(IIf([Forms]![AnnualDialog]![Dept]=41,"Casing") Or IIf([Forms]![AnnualDialog]![Dept]=64,"Open Stock"))

A parameter (either 41 or 64) is entered on a form (AnnualDialog) and the expression above is in a text box on a form where the parameter is returned.

Thanks for your help!


Is the datatype for that field a numeric or string. If it is a string try putting a "" around the 41 and the 64.


You may also need to put the .value after each of the object names that is either the 41 or the 64.
 
How do you specify numeric or string w/o doing it in code. Can you do it in the properties box? If so which field? I have been trying to figure this out with no luck. Also, should it be done in the form where I specify parameters, or in the text box where the result is shown? (Confused!!)
 
lstantliff said:
How do you specify numeric or string w/o doing it in code. Can you do it in the properties box? If so which field? I have been trying to figure this out with no luck. Also, should it be done in the form where I specify parameters, or in the text box where the result is shown? (Confused!!)


You specify the datatype when you create the table. What datatype is the field in your table?
 
ok...admittedly, I avoid IIF statements like the plague, but....

A properly formatted IIF requires expression, truepart, falsepart so in order to make this a nested IIF I believe your original expression should be:

Code:
=IIf([Forms]![AnnualDialog]![Dept] = 41, "Casing", _
           (IIf([Forms]![AnnualDialog]![Dept] = 64, "Open Stock",Null)))

which, roughly translated means that if the dept is 41, display "Casing", if not, check if the dept is 64, if so, insert "Open Stock", otherwise, leave blank.
 

Users who are viewing this thread

Back
Top Bottom