IIf Query Issue

E

echofuzz

Hi. I need help with the following IIf statement in a query:

RefresherDue:
(IIf([RefresherRequired]="Yes",(DateAdd([yyyy],[RefresherFreq],[StartDate]))," "))

What I'd like is if [RefresherRequired] is "Yes" then DateAdd
[RefresherFreq] to [StartDate]. If [RefresherRequired] is not "Yes" then I'd
like it to return null. Instead, when I open the query, it asks me for "yyyy"
in addition to the other criteria I set it up to ask for.

Hopefully this makes sense. Also, I'm not a programmer, and I haven't dealt
with databases in a very long time. I made the mistake of telling my boss
that I'd made them before and then was roped into making this one. So please
go easy on me.

Thanks!
 
F

fredg

Hi. I need help with the following IIf statement in a query:

RefresherDue:
(IIf([RefresherRequired]="Yes",(DateAdd([yyyy],[RefresherFreq],[StartDate]))," "))

What I'd like is if [RefresherRequired] is "Yes" then DateAdd
[RefresherFreq] to [StartDate]. If [RefresherRequired] is not "Yes" then I'd
like it to return null. Instead, when I open the query, it asks me for "yyyy"
in addition to the other criteria I set it up to ask for.

Hopefully this makes sense. Also, I'm not a programmer, and I haven't dealt
with databases in a very long time. I made the mistake of telling my boss
that I'd made them before and then was roped into making this one. So please
go easy on me.

Thanks!

Did you not check VBA help on the DateAdd function?

"interval Required. String expression that is the interval of time you
want to add. "

Why the brackets around the yyyy?
Why all of the extra parenthesis?

IIf([RefresherRequired]="Yes",DateAdd("yyyy",[RefresherFreq],[StartDate]),"")

The above assumes that [RefresherRequired] is a text datatype value.
If it is a Yes/No field (i.e. check box field, Boolean Number) then
use:

IIf([RefresherRequired]= -1, DateAdd(.... etc. )
 
E

echofuzz

Fred,

Thank you for your help.

The brackets were a typo on my part, and I caught it right after I posted to
the board. And the extra parenthesis is further proof that this is not my
profession. =)

I would have never gotten the -1, though. So thank you. That did it.

Thanks!
Echofuzz

fredg said:
Hi. I need help with the following IIf statement in a query:

RefresherDue:
(IIf([RefresherRequired]="Yes",(DateAdd([yyyy],[RefresherFreq],[StartDate]))," "))

What I'd like is if [RefresherRequired] is "Yes" then DateAdd
[RefresherFreq] to [StartDate]. If [RefresherRequired] is not "Yes" then I'd
like it to return null. Instead, when I open the query, it asks me for "yyyy"
in addition to the other criteria I set it up to ask for.

Hopefully this makes sense. Also, I'm not a programmer, and I haven't dealt
with databases in a very long time. I made the mistake of telling my boss
that I'd made them before and then was roped into making this one. So please
go easy on me.

Thanks!

Did you not check VBA help on the DateAdd function?

"interval Required. String expression that is the interval of time you
want to add. "

Why the brackets around the yyyy?
Why all of the extra parenthesis?

IIf([RefresherRequired]="Yes",DateAdd("yyyy",[RefresherFreq],[StartDate]),"")

The above assumes that [RefresherRequired] is a text datatype value.
If it is a Yes/No field (i.e. check box field, Boolean Number) then
use:

IIf([RefresherRequired]= -1, DateAdd(.... etc. )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top