Criteria not working with [Calculated_Values] in Access query

So I make a query, and in it I have a formula:

Small_Pets:  [Total_Pets] - [Dogs]

Then I use that field later with another formula:

Cats: [Small_Pets] - [Fish]

And all of that works great.  Query runs fast and all numbers show up correctly.  However...  Once I try to assign some criteria to the second formula everything goes to crap.

Cats:  [Small_Pets]-[Fish]
Criteria:  >3

And when I run the query now a popup window asks me to input what [Small_Pets] is?

Undaunted I tried something different.  Maybe if I had a text and used a different column it would work?  So I tried this:

Is_Crazy:  IIF([Cats]>3,"CRAZY CAT LADY!","Totally normal person")
Criteria:  "CRAZY CAT LADY"

It still didn't work, it's still asking me what [Small_pets] is, even though it works normally without a criteria.

Heroically I pushed on.  I thought that since this is going into a report I would use an imbedded query in the report that feeds off the first query I made.  The only reason I'd need the imbedded query would be to add this tricky criteria in such a way that [Small_Pets] would be contained in the first query, and thus it couldn't ask me for it again!  Brilliant, I know.  

[*.Pet_Calculator] goes into imbedded query.

[Cats.Pet_Calculator] goes into a column
Criteria:  >3

And when I run that it crashes my access...

So I give up.  What painfully obvious simple thing am I missing here?  Why won't this work?
BugHuggerNoobAsked:
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.

Helen FeddemaCommented:
Can you post the database?  Also, if you have a Cats field, the name will conflict with a calculated field called Cats: [Small_Pets] - [Fish].

Also, it might be best to have a Total_Pets calculated field that adds up the values for each type of pet, since you seem to have those values stored separately.
0
BugHuggerNoobAuthor Commented:
I don't have a Cats field that's separate.

What I'm actually doing is calculating a countdown.  So I'm using a formula to tell me how many days I have left.  So the fields I'm using are [DateCollected] and [DaysForTesting].  So I'm calculating how many days we've had the sample:

Countdown:  DateDiff("d",[DateCollected],now())

And subtracting it from how many days we have to test it:

[DaysforTesting]-[Countdown]

And it keeps asking me what [Countdown] is - but only when I put a criteria in there.  It works perfectly so long as I don't tell it <5
0
Jeffrey CoachmanMIS LiasonCommented:
Make your "DaysLeft" field something like this:

DaysLeft: [DaysForTesting]-DateDiff("d",[DateCollected],Now())

This worked fine for me...
Database24.mdb
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BugHuggerNoobAuthor Commented:
Did that new formula without a criteria, it ran great in less than a second returning a few dozen records.

Tried adding <5 as a criteria, and now it's an endless hourglass...  Not sure why Access hates criteria so much?
0
Jeffrey CoachmanMIS LiasonCommented:
FWIW, ...this used to work in older versions of Access because Access would automatically insert the full calculated field in the new expression...
Now it seems that Access just uses the calc field name...
...interesting...

Other notes:
You could have probably done the calculation in the report controls, ...then my guess is that something like this would have worked for the controlsource for txtDaysLeft:
    =txtDaysForTesting-txtCountdown

JeffCoachman
0
Jeffrey CoachmanMIS LiasonCommented:
<5 works just as well for me (no delay at all):
designyielded:
results
Make sure you run the compact repair utility on your database first
0
mbizupCommented:
Try this instead of the DateDiff function:

DaysLeft: [DaysforTesting]- (Now() - [DateCollected])
Criteria:  < 5

Also, roughly how many records are we talking about?

Does your query have other functions/criteria that could be contributing to the slow down?

Are you testing your query directly through the query grid or through a form or report which might have additional criteria or grouping?
0

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
BugHuggerNoobAuthor Commented:
DaysLeft: [DaysforTesting]- (Now() - [DateCollected])
 Criteria:  < 5

That worked perfectly!  Thanks, mbizup, you're the best!
0
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 Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.