Dear All,

I have the following fields (expressions) in my query based on certain fields from my table

Expr4: DateAdd("yyyy",18,[dob])

Expr1: Date()

Expr2: DateAdd("d",30,Date())

Expr3: IIf((([Expr1]<=[Expr4]) And ([Expr4]<=[Expr2])),"Yes","No")

Run just like that I get the desired results i.e. I am getting those records which conform to Yes and those to No.

However when I further filter the query by entering “Yes” in the criteria of the field in my effort to try and select only those records which result in “Yes” I get asked to enter the data for Expr1, then Expr4 and then Expr2.

Grateful for ideas why this is happening.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
You have to replace in Expr3 the other expression namess (Expr1, 2, 4) with their literal expressions.

PipMicAuthor Commented:

What write the entire expression inside Expr3??
Unfortunately, you cannot introduce criteria to expressions that are referred to in other expressions.  As gustav said you would need to replace the expressions in Expr3 with the actual formulas themselves.  Your final expression would end up like this:
IIf(((Date()<=DateAdd("yyyy",18,[dob])) And (DateAdd("yyyy",18,[dob])<=DateAdd("d",30,Date()))),"Yes","No")

If you're trying to see if their DOB is within the next 30 days, you can change Expr3 this way:
IIf(DateDiff("d",Date(),DateAdd("yyyy",18,[DOB])) Between 0 And 30,"Yes","No")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PipMicAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.