Allen wrote:
"use the Report property to refer to the report in the subreport control"
Suggested syntax followed.
The subreport is in a "container" on the main report. That container is
known as the subreport control. It is a different thing than the actual
subreport. In order to refer to the subreport itself rather than its
container, you need to use the Report property of the subreport control.
That is why Allen and Duane showed the syntax:
[srptFGPKConfigsSUPK_totalwt].Report
Once Access knows you are talking about the subreport, you can refer to the
subreport's HasData property:
[srptFGPKConfigsSUPK_totalwt].Report.HasData
Note that properties are preceded by a dot (.) rather than a bang (!). The
bang indicates members of a collection. The syntax:
=[Reports]![rptFGPackConfigsPKWeights]
is because rptFGPackConfigsPKWeights is a member of the Reports collection..
By contrast, HasData is a property of the subreport. In the expression in
which you said you got a comma error, you treated HasData as a member of a
collection, which it is not unless you have a field named HasData, which you
should not do because HasData is a reserved word. In your example, because
of the bang (!) Access was looking for a field or control named HasData.
Note also that on the report you don't need the full syntax to refer to the
report. Access assumes you mean the current report. That is why the syntax
Allen and Duane suggested leaves out that part.
From what I can tell you are trying to add SumWtg from
srptFGPKConfigsSUPK_totalwt] and
srptFGPKConfigsTPK_totalwt. If the second (TPK) field has no value, just
use the value of SUPK. If so, maybe something like:
=IIf([srptFGPKConfigsTPK_totalwt].Report.HasData,
[srptFGPKConfigsSUPK_totalwt].Report![SumWtg] +
[srptFGPKConfigsTPK_totalwt].Report![SumWtg],
[srptFGPKConfigsSUPK_totalwt].Report![SumWtg])
or
=[srptFGPKConfigsSUPK_totalwt].Report![SumWtg] +
IIf([srptFGPKConfigsTPK_totalwt].Report.HasData,
[srptFGPKConfigsTPK_totalwt].Report![SumWtg],0)
You will see I used a 0 instead of Null. More on that in a moment. In
either case the expression will be on one line. The line breaks are for
clarity here.
You may want to consider simplifying your report names, at least for
purposes of posting here. It would benefit you, too, in that there is less
chance of a typing error with a shorter name, and it is easier to diaganose
when there is a problem.
In any case, do not try to add Null to something else. Null is,
essentially, "unknown". Adding that to a number will result in another
unknown. Use 0 if you mean 0, an empty string if you mean that, and Null
when you specifically want Null. More here:
http://allenbrowne.com/casu-11.html
Thanks for the response, Allen! (and Al and Duane, too!)
Since you and Duane touched on the "+" part of the string I thought
I'd better explain. I'm trying to add the values of
[srptFGPKConfigsSUPK_totalwt]![SumWtg] and
[srptFGPKConfigsTPK_totalwt]![SumWtg]. There will be times when there
won't be "TPK" records so I'm trying to arrive at an expression that
will add the two [SumWtg} fields when they have values and when there
isn't one in "TPK".
Hope that clarifies.
Considering that I tried this but it's returning a comma error:
=[Reports]![rptFGPackConfigsPKWeights]![srptFGPKConfigsSUPK_totalwt]!
[SumWtg]+IIf([Reports]![rptFGPackConfigsPKWeights]![HasData],
[srptFGPKConfigsTPK_totalwt]![SumWtg]),Null)
I didn't want to tinker too much more as this may be entirely off-
track...?
See:
Avoid #Error in form/report with no records
at:
http://allenbrowne.com/RecordCountError.html
The core ideas are:
- use the Report property to refer to the report in the subreport control
- test the HasData property of the subreport.
You will end up with something like this:
=IIf([srptFGPKConfigsSUPK_totalwt].[Report].[HasData],
[srptFGPKConfigsSUPK_totalwt].[Report]![SumWtg], Null)
I did not follow the bit about trying to concatenate a null or zero-length
string onto the end of the number.
news:85f90342-fe44-4692-995f-0fd9c732a8eb@p73g2000hsd.googlegroups.com...
I've got a text box in a report that's not returning properly. Here's
its Control Source:
=[Reports]![rptFGPackConfigsPKWeights]![srptFGPKConfigsSUPK_totalwt]!
[SumWtg]+IIf(IsNull([Reports]![rptFGPackConfigsPKWeights]!
[srptFGPKConfigsTPK_totalwt]![SumWtg]),Null,"")
This returns #Error. It's definitely my IIf statement as it returns
properly when removed however there are times when
[srptFGPKConfigsTPK_totalwt].[SumWtg] will be null. In fact, this
subreport will not appear if no records exist. I suspect that this is
the problem.
How can I write this Control Source to more properly address this?
As always, thanks for you help!- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -