if-then statements in a query

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

I'm trying to filter records in a query where if one field in a recordset
contains a value of "0" and the other field in the same recordset contains
any value other than "0" to filter it from the display (i don't want to see
it), but if both fields in a recordset contain the value "0" or both fields
contain any other value other than "0" to display all records with these
conditions. Does anyone know how to do this in a query?

Thanks.
 
SELECT field1, field2, FROM tablename
WHERE field1 = 0 AND field2 <> 0

[as long as the values null are not allowed!]
 
SELECT Table1.id
FROM Table1
WHERE (((Table1.Field1)>0) AND ((Table1.Field2)>0)) OR (((Table1.field1)=0)
AND ((table1.field2)= 0));

Damon
 
oops!

WHERE NOT(field1 = 0 AND field2 <> 0)


Jim Bunton said:
SELECT field1, field2, FROM tablename
WHERE field1 = 0 AND field2 <> 0

[as long as the values null are not allowed!]

Chris said:
Hi,

I'm trying to filter records in a query where if one field in a recordset
contains a value of "0" and the other field in the same recordset
contains
any value other than "0" to filter it from the display (i don't want to
see
it), but if both fields in a recordset contain the value "0" or both
fields
contain any other value other than "0" to display all records with these
conditions. Does anyone know how to do this in a query?

Thanks.
 
Thank you.

Damon Heron said:
SELECT Table1.id
FROM Table1
WHERE (((Table1.Field1)>0) AND ((Table1.Field2)>0)) OR (((Table1.field1)=0)
AND ((table1.field2)= 0));

Damon
 
Whoa! You said you were using a query. That is a query. You can save the
query with its own name and run it to see the results. If this is for a
form, use the name of the query as the recordsource for the form.

Damon
 
Back
Top