it should be this:
=IIf(Sum([PRV]+Sum([NRV]))
but I'll get the following err msg:
"cannot have aggregated function in expression"
Main Topics
Browse All TopicsI am creating an Access report and have the following problem:
I got a goup footer with the following expression, which I named "net":
=Sum([PRV])+Sum([NRV])
Now I would like to get sum over all group in report footer, but only if the result is positive. how can I do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi mgroyal,
I think your "cannot have aggregated function in expression" is due to a problem with brackets.
Try this formula instead
=IIf((Sum([PRV]) + Sum([NRV]))>0,(Sum([PRV]) + Sum([NRV])),0)
This formula in a text box in the group footer and the report footer should give you the total of the sum of PRV + the sum of NRV if they are positive and 0 if they are negative in both sections.
However if I have understood your post above, you only want the report footer to sum the values displayed in each group footer if those sub totals are not negative.
I am not sure if this is possible. The formula to calculate the sume of PRV and NRV will total all the record entries in the group for the group footer and all the record entries for the entire report in the report footer, therfore giving you a grand total in the report footer rather than the positive total you are looking for.
The only way I can think of doing this would be to write a section of code that runs on the "On Format" section of the group footer which takes the total for that group and adds it to a variable and then display the value of the variable in the report footer. I am not sure if this is even possibel though.
Hope this helps.
Mark.
:mgroyal,
A few things are unclear:
1. Are ID A and ID B in the same group?
2. Do you want the one, "NET" Grand Sum (In the Report Footer) to be invisible when less than zero?
Or, do you want the individual Grand Sums (PRV and NRV) in the Report footer to be invisible when less than zero?
In any event,... your original formula (For NET as a Grand Sum in the Report Footer) worked fine for me without modification.
=Sum([PRV])+Sum([NRV])
All that was needed to hide or show NET, was some VBA code in the Report Footer:
Private Sub ReportFooter_Format(Cancel
If Me.Net < 0 Then
Me.Net.Visible = False
End If
End Sub
Here is my sample:
http://www.ee-stuff.com/Ex
So, in my sample NET (Grand Sum, in the Report Footer) is less than Zero (-216) and hidden.
If you open the table and change the first record's NRV from -2000 to 100, and re-open the Report, NET will be Positive, (1884), and visible.
(I also made the Detail Section hidden so you would not have to bother looking at all the individual entries)
HTH
Jeff Coachman
Business Accounts
Answer for Membership
by: rseabirdPosted on 2007-09-25 at 03:24:08ID: 19954485
You can try to use the IIF statement ]),0)+IIF( Sum([NRV]) >0,Sum([NR V]),0)
=IIF(Sum([PRV])>0,Sum([PRV
I have not tried it, by I suppose it should do the trick