Trouble with IIF statement

alfred67

Registered User.
Local time
Yesterday, 21:34
Joined
Jan 26, 2010
Messages
65
Hello

I don't understand why this doesn't work

Desc: IIf([group100]="100",[sec 100 sanitary],IIf([group100]=200,[sec 200 waterworks],IIf([group100]="300",[sec 300 Drainage],IIf([group100]="400",[sec 400 roadworks Current]))))

It only does the first one?? Maybe switch would be better??

Alfred67
 
If [group100] is not text, but in fact numbers, take the quotes away from the numbers:

Example:

IIf([group100]=100,[
 
Hello

I don't understand why this doesn't work

Desc: IIf([group100]="100",[sec 100 sanitary],IIf([group100]=200,[sec 200 waterworks],IIf([group100]="300",[sec 300 Drainage],IIf([group100]="400",[sec 400 roadworks Current]))))

It only does the first one?? Maybe switch would be better??

Alfred67


I see two issues with your IIf Statement.
  1. The value of [group100] cannot be both Text and Number, In your tests, you compare it to both Text and Number (three times as Text and once as Number. You will need to change the tests to all match the properties of [group100].
  2. Your final IIf() statement does not appear to have a value when it is False. The properties of an IIf() statement are as displayed below. More information on IIf() can be found using the following link: http://www.databasedev.co.uk/iif_function.html
Code:
[FONT=Courier New][SIZE=2][U]Part[/U]            [/SIZE][/FONT][FONT=Courier New][SIZE=2][U]Description[/U][/SIZE][/FONT]
 
[FONT=Courier New][SIZE=2][COLOR=blue][B]Expression[/B][/COLOR]      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=red][B]Required[/B][/COLOR]. Expression you want to evaluate.[/SIZE][/FONT]
[FONT=Courier New][COLOR=blue][B]Value if T[/B][/COLOR][SIZE=2][COLOR=blue][B]rue[/B][/COLOR]   [/SIZE][SIZE=2][COLOR=red][B]Required[/B][/COLOR]. Value or expression returned if [/SIZE][/FONT]
[FONT=Courier New][SIZE=2]                Expression is [COLOR=seagreen][B]True[/B][/COLOR].[/SIZE][/FONT]
[FONT=Courier New][COLOR=blue][B]Value if F[/B][/COLOR][SIZE=2][COLOR=blue][B]alse[/B][/COLOR]  [/SIZE][SIZE=2][COLOR=red][B]Required[/B][/COLOR]. Value or expression returned if [/SIZE][/FONT]
[FONT=Courier New][SIZE=2]                Expr is [B][COLOR=seagreen]False[/COLOR][/B].[/SIZE][/FONT]

Note: I got interrupted by work while I was answering, and I noticed that SOS had added a note before I could complete my post. His post in essennce agrees with my point #1.
 
Last edited:
Thanks for the help. Got it work now

Alfred67
 

Users who are viewing this thread

Back
Top Bottom