Null value in Crosstab Query

skwilliams

Registered User.
Local time
Today, 10:46
Joined
Jan 18, 2002
Messages
516
I have a viewable form whose record source is a crosstab query. I have a couple unbound fields which total specific fields on the form. It works fine.

My problem is certain fields may be null, if this happens the unbound fields won't total.

Is it possible to tell it that if I field is null to insert a zero or not figure the field in the calculation at all?

Thanks.
 
I think I would fix this issue by setting a default value of 0 (zero) to fields. Then the fields should never be null.

skwilliams said:
Is it possible to tell it that if I field is null to insert a zero or not figure the field in the calculation at all?

Those I do not know. Sorry.
 
I set the default value to zero but it still shows null
 
skwilliams said:
I set the default value to zero but it still shows null

I mean setting a default value to the objects where the crosstab query gets it's data. Sorry.
 
The crosstab query gets it's data from the table [tblAccum]. I set the default value in that table and also on the form itself.
 
skwilliams said:
The crosstab query gets it's data from the table [tblAccum]. I set the default value in that table and also on the form itself.

Hm. How is the crosstab query getting NULL values if all values in tblAccum have atleast a default value? :confused: What calculations is the crosstab doing?
 
I've attached a zipped word document showing sample data and what is being displayed in the crosstab query.

If a date doesn't contain a certain prodcode in the table, the crosstab query interprets it as a null value in the query.

Does this make sense?
 

Attachments

I am using Nz in the SQL statement for the crosstab query. It doesn't seem to be having favorable results though.

Am I using it properly?

Here's the SQL statement.

TRANSFORM Sum(Nz([tblAccum].[COUNT])) AS SumOfCOUNT
SELECT [tblAccum].[Type], [tblAccum].[RecDate], Sum([tblAccum].[COUNT]) AS TOTAL
FROM tblAccum
GROUP BY [tblAccum].[Type], [tblAccum].[RecDate]
PIVOT [tblAccum].[ProdCode];
 
Yes, I did.

I did resolve my problem though. I used the Nz in the unbound fields of the form and it's working properly now.

Thanks.
 
have you tried TRANSFORM Sum(Nz([tblAccum].[COUNT],0))

Yes, I did.

In a crosstab query, it is:-

TRANSFORM Nz(Sum(tblAccum.[COUNT]))+0
 
Jon K said:
In a crosstab query, it is:-

TRANSFORM Nz(Sum(tblAccum.[COUNT]))+0

Wow, I was having the same problem and this fixed it, thanks a ton.
 

Users who are viewing this thread

Back
Top Bottom