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
 Query containg an "IF" statement

Author  Topic 

sirmilt
Starting Member

49 Posts

Posted - 2010-07-14 : 12:30:01
I am using Access 2000 with Visual Basic 2008 and am trying to create a query to use in populating a DataGrid.

The query will only reference 4 fields in the table. One field is a code containing a string which contains either a number from 1 to 10 as text". I want the query ro result in the string "YES" if the value in the field is "1" or be blank if there is any other number.

Does anyone have any suggestions?

Milt

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-07-14 : 16:39:54
SELECT IIF(fieldNameHere like '1*' AND fieldNameHere not like '10*', "yes", "") FROM YourTable
Go to Top of Page

sirmilt
Starting Member

49 Posts

Posted - 2010-07-15 : 10:49:18
Thank you, Russel, it worked perfectly

Milt
Go to Top of Page
   

- Advertisement -