Using a calculated subtotal field in main report in access97

  • Thread starter Thread starter jberv534
  • Start date Start date
J

jberv534

I am trying to use a calculated total from a subreport as the basis fo
a report total. I tried the solution offered in another thread in thi
forum without success. The syntax
<
ReportTotal = [Reports]![ContractHours subreport]![calculated total]returns name?

<
ReportTotal = sum[Reports]![ContractHours subreport]![calculate
total]displays a dialogue asking for 'calculated field total'

Can someone help with this?

Thank you.

Jef
 
jberv534 said:
I am trying to use a calculated total from a subreport as the basis for
a report total. I tried the solution offered in another thread in this
forum without success. The syntax
<
ReportTotal = [Reports]![ContractHours subreport]![calculated total]returns name?

<
ReportTotal = sum[Reports]![ContractHours subreport]![calculated
total]displays a dialogue asking for 'calculated field total'


Sum operates on fields in the report's record source
table/query, it does not know about controls on the report.

To get what you want, add a text box named txtRunTotal to
the same section (detail?) that contains the subreport. Set
its RunningSum property to Over All and its control source
expression to:

=[ContractHours subreport].Report![calculated total]

or, if there's a chance that one or more instances of the
subreport might not have any data:

=IIf([ContractHours subreport].Report.HasData,
[ContractHours subreport].Report![calculated total], 0)

Then a text box in the report footer section can display the
grand total by using the expression =txtRunTotal

Make sure that the name of the subreport CONTROL is named
ContractHours subreport, which may be different from the
name of the report that it displays.
 
I tried your suggestion and placed the following control in the sectio
containing the subreport. It is a footer section for workorder.
=[Reports]![ContractHours subreport]![WorkorderHours] (Access97 use
the ! instead of the . I tried . but it doesn't work either.)

WorkorderHours is correctly calculated and displays in the subreport
but txtRunTotal display 'Name?' and the control in the report foote
displays the same.

Is the problem a limitation with Acess97?

Any further suggestions will be appreciated.

Jef
 
jberv534 said:
I tried your suggestion and placed the following control in the section
containing the subreport. It is a footer section for workorder.
=[Reports]![ContractHours subreport]![WorkorderHours] (Access97 uses
the ! instead of the . I tried . but it doesn't work either.)

A97, like all later versions, can use either the . or the !.
I prefer . because, in VBA, it provides intellisense and
compile time error checking. If Access wouldn't let you use
.. it's because you tried to use an invalid expression.

WorkorderHours is correctly calculated and displays in the subreport,
but txtRunTotal display 'Name?' and the control in the report footer
displays the same.

A Name error indicates that Access can not find one of the
items in the expression. It's probably because you garbled
the reference into something that expects to find the
WorkorderHours text box on the main report instead of in the
subreport. Also, make sure that you use the name of the
subreport control, which may be different from the name of
the report object it displays:
=subreportcontrolname.REPORT.WorkorderHours

Is the problem a limitation with Acess97?

No! This is a very ordinary thing to do in all versions of
Access.
 
Back
Top