I have a report that uses a crosstab as its recordsource. I have code on the report that provides overall totals using dsum because the overall total is different than the totals in the detail/group section of the report. The crosstab displays counts across by years "YR01; YR02; etc"
All the Fields have data at somepoint under a YR, however on the cross tab if no data for a particular row under a year, shows as null.
cross tab example:
[tt]
BEG TERM YR01 YR02 YR03
F 952 1
F 953 1
F 954 3
F 955 6
S 956 2
S 957 4
[/tt]
This Dsum works fine in the PageHeaderSection_Format
Me!txtYr1F = DSum("YR01", "qryRates", "BEG='F'")
This Dsum does not
Me!txtYr2F = DSum("YR02", "qryRates", "BEG='F'")
However, If I copy and paste DSum("YR02", "qryRates", "BEG='F'") directly into the immediate window (ctrl+G), it works fine.
Could the issue be nulls don't work with Dsum when in code if nulls appear first. As YR01 does have nulls, but they appear further down in Crosstab? I looked at some other related tips and found an example that wrapped dsum with Nz. I tried
Me!txtYr2F = nz(DSum("YR02", "qryRates", "BEG='F'"),0)
As before, works in immediate but not in code.
Any workaround or alternate method of obtaining result?
All the Fields have data at somepoint under a YR, however on the cross tab if no data for a particular row under a year, shows as null.
cross tab example:
[tt]
BEG TERM YR01 YR02 YR03
F 952 1
F 953 1
F 954 3
F 955 6
S 956 2
S 957 4
[/tt]
This Dsum works fine in the PageHeaderSection_Format
Me!txtYr1F = DSum("YR01", "qryRates", "BEG='F'")
This Dsum does not
Me!txtYr2F = DSum("YR02", "qryRates", "BEG='F'")
However, If I copy and paste DSum("YR02", "qryRates", "BEG='F'") directly into the immediate window (ctrl+G), it works fine.
Could the issue be nulls don't work with Dsum when in code if nulls appear first. As YR01 does have nulls, but they appear further down in Crosstab? I looked at some other related tips and found an example that wrapped dsum with Nz. I tried
Me!txtYr2F = nz(DSum("YR02", "qryRates", "BEG='F'"),0)
As before, works in immediate but not in code.
Any workaround or alternate method of obtaining result?