Summing a field in a report

MrsGorilla

Rat Race Participant
Local time
Today, 10:39
Joined
May 6, 2003
Messages
1,745
OK, I'll try to explain this as well as I can.

I have a report that is based on a table in an Access project with SQL. The table has one field that contains sums, and they are grouped by another field called CODE so that I have a sum of records for each code in the table. These are also grouped by region so my report looks like this: Region, Code, RecordCNT.

In my report, I have a text box in the report footer that contains the following statement: =Sum([RecordCNT]) which gives an overall number of records in the whole table.

My question is this: Is it possible to create another text box field in the report footer that will sum ALL of the RecordCNT fields IF the code is equal to, say A? This way I will get a total of all records associated with a certain code regardless of region.

Thanks for your help in advance.
Cindy
 
Cindy,

One way to do this is to put a new unbound
textbox in your report footer. This new
textbox is not related to your table or
query.

In the OnFormat event of your report you
can put:

Code:
Me.YourNewTextBox = DCount("[Code]", "YourTable", "[code] = 1")

Obviously, you'll have to change the names to
match your fields/tables. Also, this assumes that
code is an integer.

hth,
Wayne
 
It took me a while to get around to trying this, but I changed the DCount to a DSum and it worked like a charm!

Thanks for the great advice.
 

Users who are viewing this thread

Back
Top Bottom