Print Page | Close Window

building a string

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9650
Printed Date: 03 May 2024 at 10:32pm


Topic: building a string
Posted By: computermike
Subject: building a string
Date Posted: 09 Apr 2010 at 7:17am
I am trying to build a string using a variable and if statements, but nothing gets returned.
 
 
Can' get this to work.  Anyone see why???
 
local Stringvar MyString;
if mailto:%7b?@BidStatus - {?@BidStatus } = "" or  isnull( mailto:%7b?@BidStatus - {?@BidStatus })
    then MyString := "Bid Status: All" & "     "
    else MyString := "Bid Status: " & mailto:%7b?@BidStatus - {?@BidStatus } & "     ";
 
if mailto:%7b?@BidResult - {?@BidResult } = ""  or  isnull( mailto:%7b?@BidResult - {?@BidResult })
    then MyString := MyString & "Bid Result: All" & "     "
    else MyString := MyString &  "Bid Result: " & mailto:%7b?@BidResult - {?@BidResult } & "     ";
if mailto:%7b?@ProjectType - {?@ProjectType } = ""  or  isnull( mailto:%7b?@ProjectType - {?@ProjectType })
    then MyString := MyString & "Project Type: All" & "     "
    else MyString := MyString &  "Project Type: " & mailto:%7b?@ProjectType - {?@ProjectType } & "     ";

if mailto:%7b?@PrimeSub - {?@PrimeSub } = ''  or  isnull( mailto:%7b?@PrimeSub - {?@PrimeSub })
    then MyString := MyString & "Prime or Sub: Both" & "     "
    else MyString := MyString &  "Prime or Sub: " & mailto:%7b?@PrimeSub - {?@PrimeSub } & "     ";
MyString
 
 



Replies:
Posted By: kevlray
Date Posted: 09 Apr 2010 at 8:12am
What is it not doing?


Posted By: computermike
Date Posted: 09 Apr 2010 at 8:50am
It returns nothing.  I think it is my parameter.  I use it in the formula., then my formula is in the PageHeader section


Posted By: computermike
Date Posted: 09 Apr 2010 at 8:56am
Yes, it works if I use a database field, but if I use param it returns nothing.


Posted By: kevlray
Date Posted: 09 Apr 2010 at 9:13am

I was wondering about that myself.  I would have to do some testing to see what I get.



Posted By: kevlray
Date Posted: 09 Apr 2010 at 9:20am
I tried a quick test.  But then again, I do not know how you are using the parameters.  Are they in the select expert or just in the report?  If they are in the select expert what comparison are you using (equal, not equal, etc.).  Is the parameter set up for one value, multiple values, a range?


Posted By: computermike
Date Posted: 09 Apr 2010 at 10:17am
I have a stored procedure I pass the params to, so they are not in select expert.  The only place I use them is on the Page header so the report user can see the params they entered.  If they leave blank it returns all data, but this is coded in stored procedure


Posted By: kevlray
Date Posted: 09 Apr 2010 at 10:30am
I added a second if (I know you had four, but start simple).  I am getting curious result.  I think there may be an logic error with the if's.


Posted By: computermike
Date Posted: 09 Apr 2010 at 10:34am
I just gave up and created four seperate formulas.  I use almost exact same code, just broke into f4 formulas, don't use variable either.


Posted By: kevlray
Date Posted: 09 Apr 2010 at 10:45am
I miss copied the formula.   It is working for me.  You might want to check for nulls first in each if.  CR is funny about that.  But then again, I am not using a stored procedure for the input.
 
Lots of luck.


Posted By: computermike
Date Posted: 09 Apr 2010 at 11:58am

I found the fix, actually my co-worker, there is a setting in Formula Editor.  I set it to "Default Values For Nulls" (as opposed to "Exception for Nulls") and it works fine.  Not sure what option is called, not really labeled'




Print Page | Close Window