By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,501 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,501 IT Pros & Developers. It's quick & easy.

Access 2010 Expression not Working getting error expression entered contains the wron

P: 1
I am trying to create an expresion that if one field is equal to close or if a calculation is less than 0 then 0 else the results of the calculation.
Expand|Select|Wrap|Line Numbers
  1. IIf([CERStatus]="Closed" OR ([CERAmtApproved]-Sum(Nz([tbExpend].[AmtSpent])<0,0,([CERAmtApproved]-Sum(Nz([tbExpend].[AmtSpent]))))  
I get error message "Expression you entered has a function containing the wrong number of arguments What am I doing wrong???
Apr 28 '15 #1
Share this Question
Share on Google+
1 Reply


zmbd
Expert Mod 5K+
P: 5,397
+ In both places: Nz([tbExpend].[AmtSpent])
Is incomplete, you need to specify the return value if null.
Nz([tbExpend].[AmtSpent],0)

+ Your parentheses are not matched to each function and step.

+ I've staggered the code here for an easier following. Also, I've formatted this in the manner in which I would write the string as I tend to place each logic block within parentheses for explicit grouping and results.

You might need to place it on single line depending on your application:

Expand|Select|Wrap|Line Numbers
  1. IIf(
  2.    ([CERStatus]="Closed")
  3.     OR 
  4.       (([CERAmtApproved]-Sum(Nz([tbExpend].[AmtSpent],0)))<0),
  5.    0,
  6.    ([CERAmtApproved]-Sum(Nz([tbExpend].[AmtSpent],0)))
  7. )
the problem with this type of code...
... the longer you stare at it, the more the gremlins play tricks on your eyes!

Hope that gets you started on the right path, please let us know.
-z
Apr 28 '15 #2

Post your reply

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