PDA

View Full Version : IF Statement in A QUERY



nepotist
10-06-2008, 08:08 AM
Table A contains three fields 1) S_ID 2) B_ID 3)Min
S_id primary Key, Min is a filed that can have values A,B,C,D,E

Table B Contains 6 FILES
1) B_ID(Primary kEY) 2) Value_A.......6)Value_B
i DID DEFINE RELATIONSHIP TO WHERE Table B on one side and Table A on many side
I am trying to write a query
FIELDS:
b_ID(Table A);Min(Table A); Value_A.....Vlaue E(Table B);Cap(if ([min]= "A" , [Value A],if([Min] = "B",[Value B],.......if([Min] = "d",[value D], [VALUE D]).
When I run this query it gives me a error saying undefined IF.

I would be actually upload a example but when i try to save it in 2003 it says that it cannot be saved as some feature are available on in 2007.

Any one help me with this please

What is that I am doing wrong

CreganTur
10-06-2008, 08:41 AM
SQL has a built in If expression- 'iif'. No, I didn't make a typo- it really is iif.

It works like this:
IIF(Expression, TRUE, FALSE)
It is possible to nest IIF expressions- you can have the true or false part of an expression be another IIF.

If you need help, please C&P the SQL

nepotist
10-06-2008, 09:39 AM
Thank you Randy It was able to run I change if to iif in my syntax. but it is asking me parameter value
Please enter Value_c
I had min as C
??

nepotist
10-06-2008, 10:07 AM
Thank you randy I fixed it

CreganTur
10-06-2008, 11:01 AM
Thank you randy I fixed it

Being out for lunch solved another problem:rofl:

Knew you'd get it:clap:

Please remember to click Thread Tools -> Mark as Solved to mark your thread as Solved since your issue is resolved:thumb

nepotist
10-06-2008, 11:18 AM
Thread tools works at time and at times it dosent work, I tried doing it. when i click it , it takes me to the bottom of the page.

CreganTur
10-06-2008, 11:24 AM
Thread tools works at time and at times it dosent work, I tried doing it. when i click it , it takes me to the bottom of the page.

Really? That's strange.:think:

Maybe you should report that at the Site & Forum Related section of the forum.