SubReport Control Properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report which hosts 2 subreport controls, srSources and srUses. The
former has a textbox, txtSourcesTotal, as do the latter, txtUses. The main
report has a textbox that I would like to display the sum of txtSources and
txtUses. I have a rugged time figuring out just how to achieve this result.
Can anyone here shed some light.

Thanks
 
JonWayn said:
I have a report which hosts 2 subreport controls, srSources and srUses. The
former has a textbox, txtSourcesTotal, as do the latter, txtUses. The main
report has a textbox that I would like to display the sum of txtSources and
txtUses.


If the subreports always have at leadt one data record, the
main report text box can use an expression like:

=srSources.Report.txtSourcesTotal + srUses.Report.txtUses

where srSources and srUses **must** be the name of the
subreport controls on the main form. These names might be
different from the names of the report onject they are
displaying.

If there is any chance that an instance of a subreport might
not have any data records, use:

=IIf(srSources.Report.Hasdata,srSources.Report.txtSources,0)
+ IIf(srUses.Report.HasData,srUses.Report.txtUses,0)
 
that didnt work by the way. You didnt say what property i should set that as,
but I assume the ControlSource property. When I set it as you suggested, as
soon as i exit the property, brackets are added around each property, eg
=[srSources].Report].[txtSourcesTotal]

The end result? when I open the report, it displays #name in the textbox
 
The square brackets are just Access trying to make sure the
names are in some internal cononical form. Check to make
sure it didn't make a mistake and then don't worry about
them.

The #Name error is because you have an incorrect name in the
expression. Did you heed my warning about using the
subreport **control** names?
--
Marsh
MVP [MS Access]

that didnt work by the way. You didnt say what property i should set that as,
but I assume the ControlSource property. When I set it as you suggested, as
soon as i exit the property, brackets are added around each property, eg
=[srSources].Report].[txtSourcesTotal]

The end result? when I open the report, it displays #name in the textbox

Marshall Barton said:
If the subreports always have at leadt one data record, the
main report text box can use an expression like:

=srSources.Report.txtSourcesTotal + srUses.Report.txtUses

where srSources and srUses **must** be the name of the
subreport controls on the main form. These names might be
different from the names of the report onject they are
displaying.

If there is any chance that an instance of a subreport might
not have any data records, use:

=IIf(srSources.Report.Hasdata,srSources.Report.txtSources,0)
+ IIf(srUses.Report.HasData,srUses.Report.txtUses,0)
 
I did heed your warning by the way. I knew of that rule before. However, I
must have mistyped something somewhere, because now I did it over, paying
keener attention, and it worked.

Thanks a million

Marshall Barton said:
The square brackets are just Access trying to make sure the
names are in some internal cononical form. Check to make
sure it didn't make a mistake and then don't worry about
them.

The #Name error is because you have an incorrect name in the
expression. Did you heed my warning about using the
subreport **control** names?
--
Marsh
MVP [MS Access]

that didnt work by the way. You didnt say what property i should set that as,
but I assume the ControlSource property. When I set it as you suggested, as
soon as i exit the property, brackets are added around each property, eg
=[srSources].Report].[txtSourcesTotal]

The end result? when I open the report, it displays #name in the textbox

Marshall Barton said:
JonWayn wrote:

I have a report which hosts 2 subreport controls, srSources and srUses. The
former has a textbox, txtSourcesTotal, as do the latter, txtUses. The main
report has a textbox that I would like to display the sum of txtSources and
txtUses.


If the subreports always have at leadt one data record, the
main report text box can use an expression like:

=srSources.Report.txtSourcesTotal + srUses.Report.txtUses

where srSources and srUses **must** be the name of the
subreport controls on the main form. These names might be
different from the names of the report onject they are
displaying.

If there is any chance that an instance of a subreport might
not have any data records, use:

=IIf(srSources.Report.Hasdata,srSources.Report.txtSources,0)
+ IIf(srUses.Report.HasData,srUses.Report.txtUses,0)
 
Back
Top