View Full Version : How to write this IF statement


doncaster1986
06-11-2008, 02:09 AM
I have a database which is essentially orders and delivery processing.

I have a column called Quantity Ordered in a query at present. This column shows how many of a product are still on order. If this number is 0 I don’t know want it to show in the query.

How do I write an IF statement for this?

KenHigg
06-11-2008, 02:11 AM
IIF("[Quantity Ordered" = 0,"","[Quantity Ordered]")

KenHigg
06-11-2008, 02:12 AM
IIF("[Quantity Ordered]" = 0,"","[Quantity Ordered]")

:)

doncaster1986
06-11-2008, 02:18 AM
I am getting the error message ‘Data type miss match in criteria expression’

I have changed the name column to Qty Ordered as that is what it appears as in the database but nothing else.

doncaster1986
06-11-2008, 02:19 AM
I am pasted it in the criteria for the Qty Ordered column (wasn't 100% sure this was correct)

KenHigg
06-11-2008, 02:58 AM
This should go in the top row so that the query builder creates a new column. Something like:

MyNewColumnName: IIF("[Quantity Ordered]" = 0,"","[Quantity Ordered]")

(Assuming [Quantity Ordered] is a numeric data type)

Brianwarnock
06-11-2008, 03:06 AM
Should all those " be there?

Shouldn't it be
MyNewColumnName: IIF([Quantity Ordered] = 0,"",[Quantity Ordered])

Brian

KenHigg
06-11-2008, 03:08 AM
Should all those " be there?

Shouldn't it be
MyNewColumnName: IIF([Quantity Ordered] = 0,"",[Quantity Ordered])

Brian

Probably not - Thanks Brian. :)