Running total on a form using DSum

I

idtjes3

Hello

I'm trying to create a running sum of 4 different types of mixes and i'm
getting nowhere. The form im working on is actually a subfrom ( called
Subform - Project Mixes) embeded into a "job Information" form. The sub form
is used to enter a mix for a job when ever its purchased. Basically you
select a mix type from the list, enter a cost, quantity, and date. i want to
sum each mix type individually using DSum as follows.
Dsum("[MixQty]","Subform - Project Mixes","[MixType]=A-#90")
This gave me an error so i searched around and tried a different one.
Dsum("MixQty","Forms![SubForm - Project Mixes]","MixType=A-#90"
This also produced an error. Does anyone have any idea what wrong with my
configuration? Thanks in advance.
 
C

Cheese_whiz

Hi idtjes3,

DSUM requires the use of a table or query as the domain from which the
records are pulled (the second argument inside the parens). You are using a
form in there where there should be a table or query. Try substituting the
recordsource for the subform instead of the subform name.

CW
 
I

idtjes3

Hi,

Thanks for your response. That makes sense however when I try to swap out
for the table name i keep getting an error, "The expression you entered
contains invalid syntax"," You may have entered an operand without a
operator". Hes the equation i wrote:
=DSum("[MixQty]","Project Mixes","[MixType]=A-#90")
Where "Project Mixes" is the table name. Also should I put this equation in
an "on update" event instead so that as data is entered it's updated without
having to close the form and reopen it?
 
D

Douglas J. Steele

Since MixType is obviously a text data type, you need quotes around the
value you're using with it:

=DSum("[MixQty]","Project Mixes","[MixType]='A-#90'")

Exagerated for clarity, that's

=DSum("[MixQty]","Project Mixes","[MixType]= ' A-#90 ' " )
 
I

idtjes3

Thanks that did the trick. I copied and pasted your equation into the box
and it all worked. I tried putting the value in quotes before, but got the
same error. I don't know if it makes a difference but Access was flipping my
quotes the wrong way so maybe thats why it wasn't working. Thanks Again all
who helped.

Douglas J. Steele said:
Since MixType is obviously a text data type, you need quotes around the
value you're using with it:

=DSum("[MixQty]","Project Mixes","[MixType]='A-#90'")

Exagerated for clarity, that's

=DSum("[MixQty]","Project Mixes","[MixType]= ' A-#90 ' " )

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


idtjes3 said:
Hi,

Thanks for your response. That makes sense however when I try to swap out
for the table name i keep getting an error, "The expression you entered
contains invalid syntax"," You may have entered an operand without a
operator". Hes the equation i wrote:
=DSum("[MixQty]","Project Mixes","[MixType]=A-#90")
Where "Project Mixes" is the table name. Also should I put this equation
in
an "on update" event instead so that as data is entered it's updated
without
having to close the form and reopen it?
 

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