Filtering Records based on results of an IIF statement

P

PeterJ

I have an IIF statement in a query that returns "Yes" or "No" depending on
the value of another field.

It works fine, but how do I select either the "Yes" or "No" results. As soon
as I put something in the "Criteria" field in the query it doesn't run.

I know I could do a second query based on the first but I wanted to avoid
this if possible

Thanks

Peter
 
W

Wayne-I-M

SELECT IIf([TablelName]![SomeFieldName]="Something","Yes","No") AS Result
FROM TablelName
WHERE (((IIf([TablelName]![SomeFieldName]="Something","Yes","No"))="Yes"));


It depends on the Yes and No - if this is a Yes/No field then you need to
use -1 or 0
If its text (You have the result as "Yes" or "No") then don't forget to
enclose the criteria text in commas like this "Yes"
 
P

PeterJ

Thanks Wayne - I'll have a go at that.

I further narrowed my problem down to the fact that the IIF I was filtering
on was itself dependent on the results of another IIF statement. Seems Access
doesn't like that.

Thanks again

Peter

Wayne-I-M said:
SELECT IIf([TablelName]![SomeFieldName]="Something","Yes","No") AS Result
FROM TablelName
WHERE (((IIf([TablelName]![SomeFieldName]="Something","Yes","No"))="Yes"));


It depends on the Yes and No - if this is a Yes/No field then you need to
use -1 or 0
If its text (You have the result as "Yes" or "No") then don't forget to
enclose the criteria text in commas like this "Yes"


--
Wayne
Trentino, Italia.



PeterJ said:
I have an IIF statement in a query that returns "Yes" or "No" depending on
the value of another field.

It works fine, but how do I select either the "Yes" or "No" results. As soon
as I put something in the "Criteria" field in the query it doesn't run.

I know I could do a second query based on the first but I wanted to avoid
this if possible

Thanks

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top