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

Test for Null Variable

Status
Not open for further replies.

dukeslater

Technical User
Jan 16, 2001
87
US
I may be especially stupid today, but how can I test to see if a variable value is null in CRXIR2?

whileprintingrecords;
numbervar v_appID;
v_appID := maximum({Command.appgroupID});
v_appID;

The variable defaults to 0, but if the report returns no records then it's being assigned a null value. If it is null then I need some report elements to format differently. I could probably do the same thing with recordcount, but now it's bugging me as to how this should be done.

These don't work:

isnull(v_appID)

if not (v_appID in 1 to 20) then v_app := 99

as well as a few other less elegant stabs at it...

Thanks.



 
Try a formula in the report header of:

whileprintingrecords;
booleanvar IsNullv_appID:=false;
if isnull(maximum({Command.appgroupID})) then
v_appID :=true

Now you can reference whatever formatting in the report using the variable, as in:

whileprintingrecords;
booleanvar IsNullv_appID;
if IsNullv_appID then
crbold

-k
 
Well it's simpler than that for now but you opened my eyes. I have to test the field value (or in this case the max field value), not the variable.

whileprintingrecords;
numbervar v_appID;
if isnull(maximum({Command.appgroupID}))
then
v_appID := 99
else
v_appID := maximum({Command.appgroupID});
v_appID;

I still wonder if I'll have to test variables for nulls in the future where I won't be able to test the field value... I'll worry about that if and when it happens.

Thanks as always for the quick reply.
 
I don't see how your formule would be simpler to use for formatting in the report...

It doesn't supply any formatting information that the other formula does not.

A common thing to do is to create a simplerformula of:

isnull({table.id})

on a field that should never be null, such as a key.

then you can test for it being true or false in any formatting, ormore commonly, un suppressing a section that has a text box which states "No record returned"

-k

-k
 
I appreciate your comments and I'll file that away for future use. In this case I'm simply suppressing various company logos, so I need the actual value of the max appID to suppress all logos but one, so a boolean won't work.

The problem I was having is that if the report returned no values then the suppression formulas wouldn't work and so all logos appeared, one on top of another.

This report should never return zero records, but if it does I want no logos to appear (hence the 99).

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top