IIF with condition

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

A criteria "<100" in a numeric field is successful. Using it in an IIF
statement as IIF(1=1,<100) dosen't work. What is the proper syntax?

Dave
 
Dave said:
A criteria "<100" in a numeric field is successful. Using it in an IIF
statement as IIF(1=1,<100) dosen't work. What is the proper syntax?

Dave
What are you trying to do?

"<100" in a criteria, for the field [MoneyBet] is saying, give me all
records that have a number less than 100, in [MoneyBet].

an iff statement is: iff(criteria, , answer if criteria is met, answer
is criteria is NOT met.)

So Iff([MoneyBet]<100,"Cheapskate","Highroller") would return either of
those two answers depending on how much they bet.


Note you need to use a full expression for Criteria, not just ",100".
 
You can't place the operator inside the IIf(). You might be able to use:
< IIf(1=1,100, ...need something here...)
 
Or you might be able to use an SQL statement that looked like the following

SELECT TableName.*
FROM TableName
WHERE IIF(1=1,[SomeField]<100,True)

In Design view, I think that might look like the following:

Field: Expr1: IIF(1=1,[SomeField]<100,True)
Criteria: <> False

You could also try
WHERE ((SomeField < 100 and 1=1) Or 1<>1)

In design view that would look like
Field: SomeField
Criteria (1): <100
Criteria(2):

Field: Expr1: 1=1
Criteria(1): True
Criteria(2): False
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Thank you, describing the field with the IIF statement worked.

dave


John Spencer said:
Or you might be able to use an SQL statement that looked like the following

SELECT TableName.*
FROM TableName
WHERE IIF(1=1,[SomeField]<100,True)

In Design view, I think that might look like the following:

Field: Expr1: IIF(1=1,[SomeField]<100,True)
Criteria: <> False

You could also try
WHERE ((SomeField < 100 and 1=1) Or 1<>1)

In design view that would look like
Field: SomeField
Criteria (1): <100
Criteria(2):

Field: Expr1: 1=1
Criteria(1): True
Criteria(2): False
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Duane Hookom said:
You can't place the operator inside the IIf(). You might be able to use:
< IIf(1=1,100, ...need something here...)

--
Duane Hookom
Microsoft Access MVP
If I have helped you, please help me by donating to UCP
http://www.access.hookom.net/UCP/Default.htm
 
Back
Top