DSum Help

I have a control source on an unbound text box in a form as follow:

=Nz(DSum("[Qty]","tblCutSourceInvtySM","[ItemNo]=" & [Me].[ItemNo] & " AND “[DatRevd] >= “ & #" & (Date())-7 & "#"),0)

When I try to run the form, in the text unbound text box it display this message:  #Name?

What did I forget to put in?

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.

The error  #name?  means that it doesn't recognise the function parts.
Either wrong arguements, or wrong names.


=NZ(DSum("Qty", "tblCutSourceInvtySM", "ItemNo =" & [ItemNo] & " AND DatRevd >=#" & Date()-7 & "#"),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
Your table names/fields don't need to be in square brackets.
Also, form controls are only refered to as ME in code - not calculated controls.

What you have is half written as code and half written as calculated field (like a query)
Try this, assumig ItemNo is a number, not text:

=Nz(DSum("[Qty]","tblCutSourceInvtySM","[ItemNo]=" & [Me].[ItemNo] & " AND [DatRevd] >= #" & (Date())-7 & "#"),0)

IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

perennialAuthor Commented:
Here is a message:

The object doesn't contain the Automation object 'DatRevd.'

You tried to run a Visual Basic procedure toset a property or method for an object. However, the component does't make the property or method available for automation operations.

Check the conponent's documentation for information on the properities and mothods it maks available for automation operations.

I am not sure what it mean....did I not allow or check something?

This is ON a form, rather than in code?
Are you sure of table and field spelling?
perennialAuthor Commented:
Got it.  Let me test it out and I will let you know.

Hey prennial, is ItemNo definitely a numeric field and not a string
mind u, you probably get a different error message anyway
But if it is a string, u need to use single quotes

After trying the suggestions from the other experts

try this

select qty, itemno, daterevd from tblCutSourceInvtySM

does this query work?

if so, An alternative is to use DateDiff

Nz(DSum("Qty", "tblCutSourceInvtySM", "ItemNo = " & ItemNo.Value & " AND DateDiff('d',DatRevd,Now())>=7)"), 0)

perennialAuthor Commented:
ItemNo is a numeric field...however I believe dannywareham got.

Thanks for the suggestion.

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.