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

What's wrong with this expression?

P: 8
This in a Text Box control on an access report. I get the "wrong number of arguments" message, but what is the correct number of arguments?
Expand|Select|Wrap|Line Numbers
  1. =IIf(([Hours]=4),IIf([MAIL_LOG_TIME])<=#12:00:00 PM#),
  2. ([MAIL_LOG_DATE]&" "&DateAdd("h",4,[MAIL_LOG_TIME]),""))
May 23 '19 #1

✓ answered by ADezii

Your Syntax is incorrect, Copy-N-Paste the following to the Control Source of your Text Box:
Expand|Select|Wrap|Line Numbers
  1. =IIf([Hours]=4,IIf([MAIL_LOG_TIME]<=#12:00:00 PM#,[MAIL_LOG_DATE]+DateAdd("h",4,[MAIL_LOG_TIME]),""),"")

Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,359
Go through the expression and match all the opening parentheses to its closing parentheses
May 23 '19 #2

P: 8
Still not working, wrong number of arguemnts:
Expand|Select|Wrap|Line Numbers
  1. =IIf(([Hours]=4),IIf([MAIL_LOG_TIME])<=#12:00:00 PM#),([MAIL_LOG_DATE])&" "&DateAdd("h",4,([MAIL_LOG_TIME]))
May 23 '19 #3

Rabbit
Expert Mod 10K+
P: 12,359
Because you still haven't matched them up correctly. Show me which opening parentheses you think matches up with which closing parentheses.

Break out the innermost blocks and look at those separately before trying to combine them all together.
May 23 '19 #4

ADezii
Expert 5K+
P: 8,627
Your Syntax is incorrect, Copy-N-Paste the following to the Control Source of your Text Box:
Expand|Select|Wrap|Line Numbers
  1. =IIf([Hours]=4,IIf([MAIL_LOG_TIME]<=#12:00:00 PM#,[MAIL_LOG_DATE]+DateAdd("h",4,[MAIL_LOG_TIME]),""),"")
May 23 '19 #5

P: 8
Thanks, that worked. I am still having trouble counting out the arguments.

Thanks
-ray
May 23 '19 #6

Rabbit
Expert Mod 10K+
P: 12,359
The syntax for iif is this:
Expand|Select|Wrap|Line Numbers
  1. iif(a, b, c)
For any of those variables, you can embed another function, another iif in your example. But you must maintain the same syntax. So if you want to replace b with this:
Expand|Select|Wrap|Line Numbers
  1. iif(x, y, z)
Then you just fully replace b with that. Resulting in this:
Expand|Select|Wrap|Line Numbers
  1. iif(a, iif(x, y, z), c)
You can't just drop random variables and move the parentheses around willy nilly.
May 23 '19 #7

Post your reply

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