View Single Post
  #2  
Old November 24th, 2005, 10:11 AM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default Subreport Expressions

Presumably TotalACost is a text box in the Report Footer section of the
subreport.

Put a text box on the main report, and set its Control Source to:
=IIf([subrpt_abc].[Report].[HasData],
Nz([subrpt_abc].[Report].[TotalACost],0), 0)

When there are no matching records in the subreport, nothing shows and so
referring to the non-existent text box in the subreport causes an error. The
expression above solves that by testing the HasData property of the report
in the subreport control.

It is possible that the total could be Null, so it solves that with Nz().

Access can misunderstand the data type of calculated text boxes. To solve
that, set the Format of these text boxes to Currency (or General Number or
something.)

If you still get #Error, there is a problem with the name. Check that:
a) the calculated text boxes do not have the same Name as one of the fields,
and
b) your expression uses the name of the subreport control (which may be
different from the name of the report it contains, i.e. its SourceObject.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deiopajw" wrote in message
u...
I have a subreport called subrpt_abc
Its embedded in a report called rpt_main.

The subreport has a calculated field called TotalACost.

The main report also has a calculated field called TotalPanelCost.

I wanted to be able to add these two values together. It only seems to
work
when I create a Grand Total field in the subreport only.
However the expression I used does not work. I used:
=Reports!rpt_main!TotalPanelCost!+TotalACost

Note: when my mouse cursor exits the Control source field, the expression
all of a sudden has brackets: ie
=[Reports]![rpt_main]![TotalPanelCost]!+[TotalACost]
I think these brackets cause the error in giving me the required total
value
amount.
Why are these brackets appearing?