Query designer expression

What is wrong with this:

Total: =Sum([Amount]) where [EntryDate] between #1/1/2017# and #10/31/2017#
SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Hamed NasrRetired IT ProfessionalCommented:
Where are you using this statement?
Upload the object using it.

First attempt: remove ':'
What error are you receiving?
0
SteveL13Author Commented:
Am using in a query designer as an expression.  I can't upload due to confidentiality issues.
0
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
The query expression can result in a field, but it can not directly have its own where clause, UNLESS you make it into a  subquery (which can be correlated if need be), or you could use a Dsum expression, but beware of performance implications of doing that, if implemented wrongly.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Hamed NasrRetired IT ProfessionalCommented:
I can't upload due to confidentiality issues.
If I want to check, I need to recreate the issue, and not your database.
So I am asking you to recreate the issue with dummy data.
0
SteveL13Author Commented:
Let me see what I can put together
0
Gustav BrockCIOCommented:
You can use:

Total: =Sum(IIf([EntryDate]>=#1/1/2017# And [EntryDate]<=#10/31/2017#,[Amount],0))

Open in new window

/gustav
1

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
PatHartmanCommented:
Where are you trying to use this expression?
Hard-coding dates like this means constant change.  How should this really work?
0
SteveL13Author Commented:
I'll get something together tomorrow to show you. I thought this would be easy by if course it isn't.
0
PatHartmanCommented:
Gus gave you a suggestion for how to incorporate the date range in the sum but context matters and the expression would be different depending on where you needed to run it.
0
SteveL13Author Commented:
I was able to use Gus' code with modification:

TotalCurrentPeriod: Sum(IIf([PostDate]>=[Forms]![frmSelectDateRange]![txtStartDate] And [PostDate]<=[Forms]![frmSelectDateRange]![txtEndDate],[Amount],0))

But I'm going to award points to all who contributed, because everyone provided insight that really helps me, and start a new topic title "Query Designer Help Please".
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.