View Single Post
  #5  
Old April 21st, 2010, 03:42 PM posted to microsoft.public.access.gettingstarted
Yappy
external usenet poster
 
Posts: 7
Default Expression using Iif with dates

Dirk,
I figured it out. The solution is:

=IIf([Certification Frequency]="Annual",DateAdd("yyyy",1,[Certification
Date]), IIf([Certification
Frequency]="SemiAnnual",DateAdd("m",6,[Certification Date]),
IIf([Certification Frequency]="Quarterly",DateAdd("q",1,[Certification
Date]), IIf([Certification Frequency]="Monthly",DateAdd("m",1,[Certification
Date])))))

Thanks again!

"Yappy" wrote:

Thanks for your help. I am putting this into a text box called New Cert Due
on a form. My Certification Frequency is a combo box with the choices of
Annual, Semi-Annual, Quarterly, and Monthly. I want it to calculate the date
based on the Certification Date and the Frequency chosen.

I tried your expression and it is returning the following: #Name?

Is there something that I may be doing incorrectly?

"Dirk Goldgar" wrote:

"Yappy" wrote in message
...
The following expression results in an error telling me that I may have
entered an operand without an operator. What ami I missing?

Iif ([Certification Frequency] = “Annual”, DateAdd (“yyyy”, 1,
Certification
Date]), Iif ([Certification Frequency] = “Monthly”, DateAdd (“m”, 1,
Certification Date]), Iif ([Certification Frequency] = “Quarterly”,
DateAdd
(“q”, 1, Certification Date]), Iif ([Certification Frequency] =
“Semi-Annual”, DateAdd (“m”, 6, Certification Date]), [Certification
Date]))))


Expression entered has an invalid syntax….you may have entered an operand
without an operator



Where are you putting this expression? It's missing the usual leading "="
sign for a controlsource expression, and it's missing some left-brackets (
[ ). Maybe this:

=IIf ([Certification Frequency] = “Annual”, DateAdd (“yyyy”, 1,
[Certification Date]), IIf ([Certification Frequency] = “Monthly”, DateAdd
(“m”, 1, [Certification Date]), IIf ([Certification Frequency] = “Quarterly”,
DateAdd(“q”, 1, [Certification Date]), IIf([Certification Frequency] =
“Semi-Annual”, DateAdd (“m”, 6, [Certification Date]), [Certification
Date]))))


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)