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!

Handling nulls to UFLs

Status
Not open for further replies.

dean12

MIS
Oct 23, 2001
273
US
Preliminary look at this leads me to believe that if I try to pass a string that is NULL, CR8.5 does not call the UFL at all. Does this make sense?

My UFL reads:

Public Function xyz(byval qtqt as string) as string

msgbox "here we are"

end function

Nothing happens if the value passed is a NULL!
 
just don't pass nulls

in Crystal when you are calling the UFL do something like this

if not isnull(field) then
<call ufl>
else
<do something else with null values>;

Crystal hates nulls when used in formulas. Jim Broadbent
 
Apologize if this is a duplicate post -

Why do this test? I have three strings that can come up NULL so I have to do some type of

if not isnull(s1) then
if not isnull (s2) then
if not isnull (s3) then
.
.

etc.....

Shoot, I might as well not have the UFL.

The idea is to write the code once in a small routine and then call it as a function so I don't have to write all this IF test business every time I need to hook these three strings together.

 
Why not just convert the null to something, and then pass it?

You can accomplish this by either selecting convert null values to default in Report Options:

&quot;Selecting this check box forces the program to convert any null values to the database field default. Some databases treat a null as zero, some as a blank, and some as a special null value. &quot;

or:

or using a formula.

-k kai@informeddatadecisions.com
 
Yea, I found that option.

When I check the box to convert NULLS, CR8.5 calls my UFL. Uncheck the box and it does not execute the UFL logic.

I say this is a problem in Crystal.

 
&quot;I say this is a problem in Crystal.&quot;

LOL...sorry Dean...had to do it. There are many things in Crystal that defy normal logic. Once you learn the facts of life working with this package it isn't so bad....

AT LEAST...they allow you to create your own UFL.

instead of nesting if's like you show here:

if not isnull(s1) then
if not isnull (s2) then
if not isnull (s3) then


Just use this since if one value fails you cannot use the UFL...unless of course you want to document which values are null

if not isnull(s1) and not isnull(s3) and not isnull(s3) then
<do your UFL>
else
<do somethingelse>;

no big deal




Jim Broadbent
 
Yea, no big deal till you putz around for one or two days trying to figure out what the problem is.

So do you develop VB or C UFL's?

I stuck another question out here that is bothering me - I need to find out the DSN that is currently in use. I want to open a link to the database in my UFL VB6 code.
 
that is another topic..I have done a bit of developement in VB but most of my work is stand-alone Crystal.

Crystal has a default DSN when the report is created but you can assign the DSN along with password/username through vb parameters used to launch the report...how you do it depends on the method of launch.

Post your question as new and there are several here that can lead you better than I....that is the beauty of this site...each of us seems to be good at different aspects of using Crystal.

Don't stew over a problem for days...if you describe your problem with a simple yet comprehensive example, there will be no shortage of good advise.

Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top