vrkcamry
05-30-2009, 11:47 AM
I have 10 fields lined up horizontally in a report. Some of these fields are made invisible fields on the report programatically.
i want a formula to sum only the fields that are visible and show me the result on a separate field. Is this possible at all?
Mr. B
05-30-2009, 01:15 PM
vrkcamry,
Yes, what you propose is possible.
Add the normal text box as set it up to sum each of the columns that you want to have a total for. If you are unfamiliar with how to sum in a report, check out this link.
http://office.microsoft.com/en-us/access/HA011224441033.aspx
The just use the same type of code that you eveidently already have running to decide to show or hide various controls based on some criteria. At the point where you are making the decision to show or hide a specific columm, just add a statement to make the control that sums that column either visible or not using the same criteria. You can use one of the statements below.
Me.NameOfControl.Visible = false
or
me.NameOfControl.visible = true
HTH
vrkcamry
05-30-2009, 02:18 PM
Thank you for your suggestion.
Right now, I got this to work by summing visible fields in the Detail Format event of the report.
I have a feeling this report would take a long time to open when the number of records in the report increase.
Is there a better way to do this? Like static calculations on the "Total" Control using IIF? just for the same of improving performance...
Mr. B
05-30-2009, 02:24 PM
Having a text box control that does the Sum is the only way I know to make it happen as reports as susposed to be designed. I have seen a few times when a developer would use VBA code to run various queries to product calculations and then simply write the calculated value to an unbound control in a report.
Most of the time when I see this type of data acquisiton for a report it is due to poor database structure design.
HTH