Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 How to do this (query with IIF function)

Author  Topic 

darkelf
Starting Member

2 Posts

Posted - 2003-08-11 : 07:23:29
Hello guys.

First my machine;
Windows XP
MS Access XP

The problem;

One form with a field named cboCB (only two values D and G)
one table (tblKMValues) with one field IDKM (values: 10, 20, 30, 40... till 200)
One query from the table tblKMValues)

on this query i what to do something like this

Select IDKM IIF(cboCB = D;IDKM >=180;IDKM)
From tblKMValues

Resuming the thing

If the cboCB is D limit the IDKM to 180, IF cboCB is G show all.

Thks for your help in advanced

DarkElf

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-08-11 : 07:47:00
You need to do this in your WHERE clause:

SELECT * FROM tblKMValues
WHERE cboCB = 'G' OR IDKM >=180

That means:

If cboCB <> 'G', then IDKM must be greater than or equal to 180.

- Jeff
Go to Top of Page

darkelf
Starting Member

2 Posts

Posted - 2003-08-11 : 07:53:43
Hi

thaks for your fast reply. It works and it's so simple that i'm feel kind stupid.

Darkelf
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-08-11 : 08:21:05
darkelf -- no problem... it's one of those things that is not obvious at all; implementing an "if-then" in a query's criteria is one of the most confusing things people do in SQL.

Most assume a CASE or an IIF() is the way to go, but it's really not !

- Jeff
Go to Top of Page
   

- Advertisement -