View Full Version : Use Data from SubReports


chile19
12-30-2004, 12:23 PM
I have 2 subreport on the main report. On the main report I need to print up the sum of some textboxes from each subreport...... no idea.

Please help!!!
Thanks any way

Fizzio
12-31-2004, 01:40 AM
Calculate the sums in each subreport then add them (or whatever) in the main report.

You will need (in each subreports footer) a control that has the controlsource such as =Sum([FieldtoSum])

Then on your main report the controlsource would need to be something like

=Reports![MainReport].[Subreport1].Report![Control1] + Reports![MainReport].[Subreport2].Report![Control2]

where Control1 + 2 are the calculated controls in your subreports

chile19
12-31-2004, 04:51 AM
Great Help.
Thanks a lot.
:)

Rich
12-31-2004, 06:04 AM
To avoid possible errors with empty subReports you should use the HasData method ;)

Fizzio
12-31-2004, 06:22 AM
To avoid possible errors with empty subReports you should use the HasData method ;)
Good point :rolleyes:

chile19
12-31-2004, 06:50 AM
Sorry but what is the HasData method, and where can I find some info about it?

razorking
12-31-2004, 03:06 PM
From Access Help:


You can use the HasData property to determine if a form or report is bound to an empty recordset.

Setting

The HasData property is set by Microsoft Access. The value of this property can be read only while printing or while in Print Preview.

Value Description
–1 The object has data.
0 The object doesn't have data.
1 The object is unbound.


You can get the value of the HasData property by using a macro or Visual Basic.

Remarks

You can use this property to determine whether to hide a subreport that has no data. For example, the following expression hides the subreport control when its report has no data.

Me!SubReportControl.Visible = Me!SubReportControl.Report.HasData :eek:

Rich
12-31-2004, 03:20 PM
Actually it doesn't need any vba
=IIf([SubReportName].[Report].[HasData],[SubReportName].[Report]![TextBox],0)