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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reports with Null fields

Status
Not open for further replies.

sbianco

Programmer
Mar 3, 2003
5
US
If a single database has 3 fields (table.fld1, table.fld2, table.fld3). Each field can contain data or be empty (null). How do I generate a report (formula) based on whether the field contains data or is empty.

Meaning, how do I generate a CR on fld1 if, fld2 and fld3 are empty. On fld1 and fld2 if, fld3 is null, etc.

I don't have a problem building the 6 different CR's showing the 6 different possible report field conbinations using VS.Net.

Thanks Steve

 
A formula field will stop and return nothing if it encounters an unexpected Null. It's a 'feature' of Crystal, and one that I personally find hugely irritating.

There are several ways to get round this: my choice would be one formula field to test each value, with If isnull(field) as the first test. And then a fourth formula field to pull together the resutls Madawc Williams
East Anglia
Great Britain
 
Or File/Report Options/Convert NULL Field Value to Default
 
Try this:
Go to File/Options... (or Report Options... if you only want to change the Null handling on this report) on the Reporting tab, check the "Convert NULL field values to Default" box.

Mike
 
I'm sorry but I dont quite understand. Can you give some more details

case 1
if I want a report when fld1 has data but fld2 and fld3 are empty what does the "IF" formula for fld1 do if it's not empty and how is it different from the formula from fld2/3 which are empty
if (not IsNull ({table.fld1})) then fld1 := fld1 // ?
if IsNull ({table.fld2/fld3}) then fld1 := fld1 // ?

case2: - Convert NULL Field Value to Default
Not sure why this is important. In Access DB I don't have a default value (i.e. zero) assigned for fld1-3. Should I? I'm I testing for zero in the "if"(if(table.fld1 = "0")then ...)?

case3 - Simple New Question
If I format a field by checking off the "Can Grow" box and the field grows beyond the size of the block, how can I format the other field blocks so they are pushed down to make room for the block that is growing?

Thanks Steve
 
Case 1:
You said that any of the fields could be null. If that's the case, you need to check for the null condition. This is would be done in case you don't want do the "Convert..." or the "Convert..." doesn't work.

Your formula(s) would be:
If isnull({field1} then "" else {field1}

Case 2:
I may be wrong concerning the converting, and I'm sure someone will/should set me straight.
You don't need to set a default, Crystal sets it for you. Nulls for numbers are changed to zeros and strings are changed to "" (empty strings).

Case 3:
It's not "good practice" to stack fields in the same band if you use the "can grow". If you want to stack them, insert another band and move the fields into the different bands
Code:
"Bad"
---------------------------------------------------------
Details                 [field]
                        [field]
---------------------------------------------------------

"good"
---------------------------------------------------------
DetailsA                [field] 
---------------------------------------------------------
DetailsB                [field]
---------------------------------------------------------




Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top