DSum Problem

M

muneca

I have a DSum in a text box's Control Source:
=DSum("[Quantity]*[UnitPrice]","tblInvoice","BillDate=#" &
DateAdd("m",-1,me!cboSelectDate) & "#")

I continue to get the #Name? error in the text box when I open the form.
The field names are correct, as is the table name and cboSelectDate has a
date when the form is loaded. Just to see what would happen I also wrote an
identical function passing the value in cboSelectDate to it and using the
result of the function as the caption for a label on the form and it works
just fine.

It just bothers me that I can't get DSum to work in the text box as it should.
 
K

Ken Snell \(MVP\)

=DSum("[Quantity]*[UnitPrice]","tblInvoice","BillDate=#" &
DateAdd("m",-1,[cboSelectDate]) & "#")
 
M

muneca

It works. Thank you very much. I guess it didn't recognize me.cboSelectDate.

Ken Snell (MVP) said:
=DSum("[Quantity]*[UnitPrice]","tblInvoice","BillDate=#" &
DateAdd("m",-1,[cboSelectDate]) & "#")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



muneca said:
I have a DSum in a text box's Control Source:
=DSum("[Quantity]*[UnitPrice]","tblInvoice","BillDate=#" &
DateAdd("m",-1,me!cboSelectDate) & "#")

I continue to get the #Name? error in the text box when I open the form.
The field names are correct, as is the table name and cboSelectDate has a
date when the form is loaded. Just to see what would happen I also wrote
an
identical function passing the value in cboSelectDate to it and using the
result of the function as the caption for a label on the form and it works
just fine.

It just bothers me that I can't get DSum to work in the text box as it
should.
 
K

Ken Sheridan

Its also a good idea to ensure that the date literal is in an internationally
unambiguous format:

=DSum("[Quantity]*[UnitPrice]","tblInvoice","BillDate=#" &
Format(DateAdd("m",-1,[cboSelectDate]),"yyyy-mm-dd") & "#")

Ken Sheridan
Stafford, England
 

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

Top