422,904 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,904 IT Pros & Developers. It's quick & easy.

Wrong number of arguments with nested IIF's

P: 1
Expand|Select|Wrap|Line Numbers
  1. UserState: Left(Trim(IIf([Temp10] Like "*NEW USER'S REGION*",
  2.   Trim(Replace([Temp10],"NEW USER'S REGION:","")),
  3. IIf([Temp9] Like "*NEW USER'S LOCATION INFO: USA-FSA*",
  4.   Replace([Temp9],"NEW USER'S LOCATION INFO: USA-FSA>>","")),
  5. IIf([Temp9] Like "*NEW USER'S LOCATION INFO: USA-FRAC-FRA*",
  6.   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
5 Days Ago #1

✓ answered by zmbd

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 :) )

Share this Question
Share on Google+
2 Replies


zmbd
Expert Mod 5K+
P: 5,087
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 :) )
5 Days Ago #2

NeoPa
Expert Mod 15k+
P: 30,842
Perfect answer to the question. BA set ;-)
4 Days Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.