Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dSUM in code behind Report Null issue; source is crosstab

Status
Not open for further replies.

sxschech

Technical User
Jul 11, 2002
1,033
US
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?
 
Follow up...It is working fine now, even with nulls, didn't need nz. However, don't know what I did to get it working. Perhaps saving and closing both the report and the query and then reopening the report did it? A puzzle indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top