Wrong number of arguments with nested IIF's

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • haydenbl
    New Member
    • Jul 2018
    • 1

    Wrong number of arguments with nested IIF's

    Code:
    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
    Last edited by zmbd; Jul 10 '18, 06:40 PM. Reason: {z: placed required code tags}
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    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:
    Code:
    So start with the Left([iCODE]_[/iCODE],2)
    Then start placing each level Left(Trim([iCODE]_[/iCODE]),2)
    Left(Trim( IIF([iCODE]?[/iCODE],[iCODE]T[/iCODE],[iCODE]F[/iCODE]) ),2)
    Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",[iCODE]T[/iCODE],[iCODE]F[/iCODE]) ),2)
    Left(Trim( IIF([Temp10] Like "*NEW USER'S REGION*",Trim(Replace([Temp10],"NEW USER'S REGION:",[iCODE]F[/iCODE]) ),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 :) )
    Last edited by zmbd; Jul 10 '18, 07:07 PM.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      Perfect answer to the question. BA set ;-)

      Comment

      Working...