I am using Access 2007 on Windows XP. I am trying to build a report that contains up to 4 subreports. The main report should add the subtotals of the 4 subreports. Not every report will contain all subreports so I am using IIF to identify subreports with no records. In the main report I can add three IIF routines just fine.
Here is my control source expression that works:
=IIF([srptInvoiceDetail].[Report]![HasData], Nz([srptInvoiceDetail].[Report]![txtSubTaskTotal],0),0) +
IIF([srptAddFLR].[Report]![HasData], Nz([srptAddFLR].[Report]![txtFLRTotal],0),0) +
IIF([srptAddParts].[Report]![HasData], Nz([srptAddParts].[Report]![txtPartsTotal],0),0)
If I add the 4th IIF for the last subreport I exceed the 256 character limit of the expression field.
How can I work around this limitation?
I can envision two ways to accomplish this:
1. Perform the IIF in the subreport to ensure that a valid value is passed to the main report. If the subreport has records, the value would pass through correctly. If the subreport has no records, the HasData flag will reflect that and the value will be set to zero.
2. Perform the IIF calculations in VBA in Report_Open (or some other report event). The IIF calculations would be performed in the Report_Open event and pass the total to the unbound text box in the main report.
Any insight and recommendations would be greatly appreciated.
Thanks,
Jim