I've posted this question a few days ago but I think I didn't properly describe it. Here goes again, giving my best amateur assessment of the situation.
I have a report with four subreports. Each of these subreports is fed by a different query, generating any number of numeric records and having a 'total' field adding up the total. The main report has a "grand total" field which is supposed to add up the four individual totals from each subreport.
All works fine as long as each of the four subreports actually has records, however the queries are fed by user input and frequenly, only two or three of the subreports actually have any records. On the ones that don't, the total field won't even appear. Which is fine with me layoutwise, but this seems to be causing trouble when trying to add the fields up.
When at least one of the four subreports generates no 'total' value, the calculation in the 'grand total' field fails. I've been recommended to try the Nz() function to convert null values to 0 for the purposes of the calculation, but it doesn't help at all. I suspect this is because I'm not actually dealing with records where the column I'm adding up has a null value, but with the absence of any records matching the query criteria.
Explaining it graphically:
SUBREP1
10
4
5
Total1: 19
SUBREP2
[no records]
[total field isn't shown]
SUBREP3
5
Total3: 5
SUBREP4
4
7
Total4: 11
MAINREP
Grandtotal: Total1+Total2+Total3+Total4
Again, the calculation works just fine as long as all four of those totals exist, so the references to the subreports are in order. But as soon as one of them doesn't exist because it wasn't fed any records, the calculation fails.
What I want is that if a total doesn't exist, a 0 is taken for it instead. I've tried putting Nz() around each part of the calculation in the grandtotal field, as well as on the individual total fields on the subreports. Neither did me any good.
Can anybody help me out here? It's been stalling me for days now, and I can't put off finishing this report much longer.
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
I have a report with four subreports. Each of these subreports is fed by a different query, generating any number of numeric records and having a 'total' field adding up the total. The main report has a "grand total" field which is supposed to add up the four individual totals from each subreport.
All works fine as long as each of the four subreports actually has records, however the queries are fed by user input and frequenly, only two or three of the subreports actually have any records. On the ones that don't, the total field won't even appear. Which is fine with me layoutwise, but this seems to be causing trouble when trying to add the fields up.
When at least one of the four subreports generates no 'total' value, the calculation in the 'grand total' field fails. I've been recommended to try the Nz() function to convert null values to 0 for the purposes of the calculation, but it doesn't help at all. I suspect this is because I'm not actually dealing with records where the column I'm adding up has a null value, but with the absence of any records matching the query criteria.
Explaining it graphically:
SUBREP1
10
4
5
Total1: 19
SUBREP2
[no records]
[total field isn't shown]
SUBREP3
5
Total3: 5
SUBREP4
4
7
Total4: 11
MAINREP
Grandtotal: Total1+Total2+Total3+Total4
Again, the calculation works just fine as long as all four of those totals exist, so the references to the subreports are in order. But as soon as one of them doesn't exist because it wasn't fed any records, the calculation fails.
What I want is that if a total doesn't exist, a 0 is taken for it instead. I've tried putting Nz() around each part of the calculation in the grandtotal field, as well as on the individual total fields on the subreports. Neither did me any good.
Can anybody help me out here? It's been stalling me for days now, and I can't put off finishing this report much longer.
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)