PDA

View Full Version : Counting String Null Values



torgerjl
10-13-2008, 12:44 PM
I am writing a Crystal Report that is counting a string value field; it will not recognize/count the null values. For example, if F2 is a server name and one field is empty, it just eliminates it from the count; I need to include it.

Any suggestions?

Oorang
10-15-2008, 12:34 AM
Personally I would just edit the source query to pull the field a little differently. Instead of just pulling the field "raw" I would use the Replace expression and replace null with a string saying something "Name not found" or something suitable. That should get it included in your count. Check here for more detail on the Replace function if you have not used it: http://msdn.microsoft.com/en-us/library/ms186862.aspx

torgerjl
10-15-2008, 06:18 AM
Crystal uses an ODBC connection to a db table. If I add the replace function to the formula editor as you suggest I get a boolean result, which is still blank.
SELECT REPLACE({db.F3},'',"blank")

Oorang
10-16-2008, 04:59 AM
Hmm you shouldn't be getting a boolean result, double check your syntax your must be accidently performing a comparison. But while you are double checking, also check the documentation on Replace, and make sure it handles Nulls. The more I think about it you might actually need to be using If IsNull etc.

Mavyak
10-18-2008, 12:57 PM
For SQL Server you can use the ISNULL() function.
SELECT ISNULL(DB.F3, '')

For MS Access you can use the Nz() function:
SELECT Nz(DB.F3, '')