IIf Function - False condition problem

jlang

New member
Local time
Today, 20:20
Joined
Dec 12, 2006
Messages
2
Hi, I've used the following code in the Criteria line in a query (Access 2000)and the false condition doesn't seem to work. If I replace the false condition >0 with any other single value (say 1) it works fine.

IIf([Forms]![frmReports]![cboServArea]>0,1,>0)

I'd be grateful for any help,
Thanks
 
You have the syntax wrong. You are supposed to be setting the values to return if true and if false.
IIf([Forms]![frmReports]![cboServArea]>0,1,>0)
is incorrect as a value, unless it is a string, cannot be >0.

IIF([Forms![frmReports].[cboServArea]>0,1,0)
would return a 1 if true and a zero if false.
 
iif

You must specifiy what you want for your false value. Remove the > in the false part and replace with 0.
 
jlang said:
Hi, I've used the following code in the Criteria line in a query (Access 2000)and the false condition doesn't seem to work. If I replace the false condition >0 with any other single value (say 1) it works fine.

IIf([Forms]![frmReports]![cboServArea]>0,1,>0)

I'd be grateful for any help,
Thanks
What are you trying to do exactly ? Is it appears above you have "if the form value >0 then return the value 1, otherwise, return >0" How can a function return >0 ??? It has to return a value not a condition.
What do you want to return if the value on the form is not >0?

Stopher
 
Put the criteria in a new column in the query grid like the following, using the correct field name:-
-----------------------------------
Field: IIf([Forms]![frmReports]![cboServArea]>0,[FieldName]=1,[FieldName]>0)

Show: uncheck

Criteria: True
----------------------------------

which is derived from Jon K's Basic Criteria Format in this thread:-
http://www.access-programmers.co.uk/forums/showthread.php?t=103312

^
 
Thanks for your quick replies. EMP, that works great. Thanks!
 

Users who are viewing this thread

Back
Top Bottom