Sum Records In Subrpt For Main Rpt

renenger

Registered User.
Local time
Today, 15:37
Joined
Oct 25, 2002
Messages
117
Hello. I hope someone can help me. I have a report with several subreports. I am totaling $ amounts to get some statistics for our customer service department. I have subrptForecastSummary that shows the total $ amounts for each delivery area. I have an unbound text box in my report header that I want to total just areas 1 and 2 in. Not all 4 areas. I am not sure how to do this. I tried doing it with code but it only totals the area 1 it does not add area 2.

If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "1" or "2" Then
Me.North = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])
I also tried

Dim North1Total as Integer
Dim North2Total as Integer

If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "1" Then
North1Total = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])

If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "2" Then
North2Total = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])

End If
End If

Me.North = North1Total + North2Total


I get an overflow error with this. Anyone have an idea?

Thanks
Brandy
 
With your first example I would think you would want:

Code:
If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] [b]< 3[/b] Then
Me.North = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])

Assuming the value of [Area] can only be 1,2,3 or 4, summing when [Area] is less than 3 will catch both 1 and 2.

The long way to do this would be:

Code:
If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "1" or [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "2" Then
Me.North = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])

Unless you need separate totals for north1 and north2, the above code should work.

I think the problem with your second example is that your "If / End If" statements were nested. You probably want the first "End If" to go before the second "If" statement.
 
Still Trying

It is still only total Area 1. It's not adding in Area 2
 
Help

Ok. I have changed my reports a little bit. We are going to get more specific with the areas. So 1 = SouthEast 2 = SouthWest etc.

So I have a text box that I want to only show the total for Area 2. It will only total Area 1. Not sure how to get around that.

If [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Area] = "2" Then
Me.SouthEastSales = ([Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Total] + [Reports]![rptCSInstallDetail]![subrptForecastSummary].[Report].[Options])
 
That's confusing that it only sums area 1.

I would suggest zipping a scaled down database containing only the necessary forms/queries/tables/reports and attach it to a post here.
 

Users who are viewing this thread

Back
Top Bottom