435,319 Members | 2,115 Online
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

# Wrong number of arguments with nested IIF's

 P: 1 Expand|Select|Wrap|Line Numbers UserState: Left(Trim(IIf([Temp10] Like "*NEW USER'S REGION*",   Trim(Replace([Temp10],"NEW USER'S REGION:","")), IIf([Temp9] Like "*NEW USER'S LOCATION INFO: USA-FSA*",   Replace([Temp9],"NEW USER'S LOCATION INFO: USA-FSA>>","")), IIf([Temp9] Like "*NEW USER'S LOCATION INFO: USA-FRAC-FRA*",   Replace([Temp9],"NEW USER'S LOCATION INFO: USA-FRAC-FRA>>","")))),2) this is my code for return the user state from two different fields. The error I get is wrong number of arguments. any help you can give me would be greatly appreciated... Thanks Jul 10 '18 #1

Your groupings are off, it will take a while to step through them...

Looks like this is in an SQL/Query not VBA yes?

I usually approach these large groupings stepwise:
Expand|Select|Wrap|Line Numbers
1. So start with the Left(`_`,2)
2. Then start placing each level Left(Trim(`_`),2)
3. Left(Trim( IIF(`?`,`T`,`F`) ),2)
4. Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",`T`,`F`) ),2)
5. Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",Trim(Replace([Temp10],"NEW USER'S REGION:",`F`) ),2)
6. Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",Trim(Replace([Temp10],"NEW USER'S REGION:","") ),2)
By line 6 you can see that at this point it looks like you've finished the first `IIF()` within the first `Trim()` and then it appears that you are attempting to append other information... which will not work without an "&" to concatenate the string for the `left()`... in short, you do not appear to have a properly nested `IIF()`

If you will explain what you are attempting it might help us (we can guess; however, much better to know :) )

 Expert Mod 5K+ P: 5,397 Your groupings are off, it will take a while to step through them... Looks like this is in an SQL/Query not VBA yes? I usually approach these large groupings stepwise: Expand|Select|Wrap|Line Numbers So start with the Left(`_`,2) Then start placing each level Left(Trim(`_`),2) Left(Trim( IIF(`?`,`T`,`F`) ),2) Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",`T`,`F`) ),2) Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",Trim(Replace([Temp10],"NEW USER'S REGION:",`F`) ),2) Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",Trim(Replace([Temp10],"NEW USER'S REGION:","") ),2) By line 6 you can see that at this point it looks like you've finished the first `IIF()` within the first `Trim()` and then it appears that you are attempting to append other information... which will not work without an "&" to concatenate the string for the `left()`... in short, you do not appear to have a properly nested `IIF()` If you will explain what you are attempting it might help us (we can guess; however, much better to know :) ) Jul 10 '18 #2