adding field totals in reports

M

Mark

Hi all,

In a report control source I have the following code:

=[Match1]+ [Match2]+ [Match3]+ [Match4]+ [Match5]

Each one of the above fields ("[Match1]"
through "[Match5]") has either a 1 or 0 value, which
basically displays something like: 10010 when I use the
above code. I would like to have the above code total up
the number of 1's. If the output is 10010 then I would
like to have "2" being displayed. I have tried something
like:

=Count([Match1]+ [Match2]+ [Match3]+ [Match4]+ [Match5])

But it is not working out right, nor if I use Sum. All
this is in the detail portion of the report.

Thanks for any help!
 
J

Jim/Chris

I have this post from Dirk Goldgar(MVP). I have found very
useful. Note #3.

Check the following points:

(1) The summing text box must be in a group or report
footer or header section. Usually it will be in a footer
section. Don't put it in a page footer or header.

(2) The name of the summing text box must not be the same
as the name of a field in the report's recordsource. So if
your text box is summing the [Retail Price] field, as with
the controlsource you posted, name it something like
"txtTotalRetail".

(3) The argument of the Sum() function must be a field or
an expression of fields in the report's recordsource; it
can't be the name of an unbound or calculated control. If
you have a calculated control, for example if [Retail
Price] is a text box with controlsource
"=[WholesalePrice]+[Markup]", where [WholesalePrice] and
[Markup] are fields in the recordsource, then you must
repeat the calculation in the argument to the Sum()
function, as with this controlsource:
"=Sum(WholesalePrice]+[Markup])".

Jim
 
D

Douglas J. Steele

What's the data type of the fields? Looks as though it's treating them as
Text.

You could try:

=CInt([Match1])+ CInt([Match2])+ CInt([Match3])+ CInt([Match4])+
CInt([Match5])

Of course, you really should look into Normalization. Having field names
like that is a sure sign that you've got repeating groups.
 

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