Reference subreport control if HasData

W

Wayne-I-M

Hi

I could do this with a sub query but would like to see if it's possible in
the report itself.


I have a report with a sub report liked to client's ID
The subreport is in the details section
Some of the sub reports have no data (they are not shown)

I am trying to reference a control on the sub report and bring the total of
these into the main report header or footer.

It's not working

=Sum(IIf(SubReportName.Report.HasData,SubReportName.Report!ControlName,0))

Note - The control I am trying to sum is in the report footer of the
subreport - currency format

Any ideas ??
 
K

Ken Snell [MVP]

Your syntax is completely correct for the main report's control's
ControlSource expression for the IIf part. However, you're trying to use the
Sum function on a control instead of a field.

Do the Sum function in the subreport, and then use this expression to read
that value:

=IIf(SubReportName.Report.HasData,SubReportName.Report!ControlNameWithSummedValue,0)
 
W

Wayne-I-M

Hi Ken

Sorry I sould have said
The Sum is to sum all the results in the main report header.

eg.
In SubReport's report footer control called ABC

In the main report header a control with the source of
=IIf(SubReportName.Report.HasData,SubReportName.Report!ABC,0)

and it's this that does not work

any ideas ?



--
Wayne
Manchester, England.



Ken Snell said:
Your syntax is completely correct for the main report's control's
ControlSource expression for the IIf part. However, you're trying to use the
Sum function on a control instead of a field.

Do the Sum function in the subreport, and then use this expression to read
that value:

=IIf(SubReportName.Report.HasData,SubReportName.Report!ControlNameWithSummedValue,0)
 
K

Ken Snell [MVP]

"Does not work" means what? Do you get an "#Error" in the textbox? Do you
get a blank value? Do you get an error message?

Putting a control in the main report's header that reads a value from a
subreport's control may be a problem (have never tried to do that) because
of timing -- header will be "printed" long before the subreport is rendered,
so it's possible that the header won't see the subreport at that time?


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Wayne-I-M said:
Hi Ken

Sorry I sould have said
The Sum is to sum all the results in the main report header.

eg.
In SubReport's report footer control called ABC

In the main report header a control with the source of
=IIf(SubReportName.Report.HasData,SubReportName.Report!ABC,0)

and it's this that does not work

any ideas ?



--
Wayne
Manchester, England.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top