View Full Version : Other option for DSum


cbayardo
04-23-2004, 10:26 AM
Does anyone know another option for DSUM in a Report?
In my Report I have a grouping of a field called Ext.Which is the Extension of a telephone. I insert the formula in the Header of that group. It looks like this:
=DSum("[Cost]","MyTable","[Type] = '2' ")
Cost being the field with the value I want to sum, MyTable being :rolleyes: ...MyTable and Type is the field that check to see what values to sum.
Make sense?
This is not returning what I want, instead it returns the total of all the Extension.

Any ideas of what I am doing wrong?
Thank you

Pat Hartman
04-23-2004, 01:08 PM
You need to alter the criteria so that it selects the correct set of records to sum.

=DSum("[Cost]","MyTable","[Type] = '2' AND [SomeOtherField] = " & [SomeOtherField])

A better solution is to create a totals query that sums the cost as you want it summed. Then change the report's recordsource query to join to the totals query. You can then select the sum field from the report's recordsource rather than having to run the dsum.

cbayardo
04-23-2004, 03:46 PM
Thanks for your reply,
I get an Error with this
=DSum("[Cost]","MyTable","[Type] = '2' AND [SomeOtherField] = " & [SomeOtherField])
Is there something that I am missing here? The "& [SomeOtherField] means that it is concatenating?

The Totals Query works, but I would have to create one query for each Type. I think, unless I am doing something wrong here.

Thanks again

Rich
04-24-2004, 12:05 AM
Post the SQL of your Totals Query

Pat Hartman
04-25-2004, 09:06 AM
cbayardo,
You need to substitute your own field names. Right now your criteria is only [Type] = '2' From what you said, I believe that you need at least one more criteria.

Also, is Type numeric? If it is, you need to remove the apostrophe's from around the 2.