Link to home
Start Free TrialLog in
Avatar of jwebster77
jwebster77

asked on

Formula field in Crystal Reports - Error

I have a formula field in crystal reports.  In this formula field I have the code:

NumberVar Length_of_Last2;
Length_of_Last2 := Length({vwPullAllActiveChildOther.LastName});
IF RIGHT({vwPullAllActiveChildOther.HouseHold},Length_of_Last2) = {vwPullAllActiveChildOther.LastName} THEN
   {vwPullAllActiveChildOther.FirstName}
ELSE
   {vwPullAllActiveChildOther.FirstName} + " " + {vwPullAllActiveChildOther.LastName};

Open in new window


 I have two views linked together in crystal reports.  In some cases though, there may not be a record in vwPullAllArvieChildOther so if there isn't, I am getting an error in the formula above.  My question is, how can I ignore the formula if now records exist in vwPullAllArchiveChildOther?
Avatar of vasto
vasto
Flag of United States of America image

Check the value of the field for nulls

if not isnull(vwPullAllArchiveChildOther.LastName) then
 ..... your code here ...
else

default value
Avatar of jwebster77
jwebster77

ASKER

I did as mentioned, see below.  When I run it it says at the last else not part of the code.  (the bolded area is my original code.

if not isnull({vwPullAllActiveChildOther.LastName}) then
[b]NumberVar Length_of_Last2;
Length_of_Last2 := Length({vwPullAllActiveChildOther.LastName});
IF RIGHT({vwPullAllActiveChildOther.HouseHold},Length_of_Last2) = {vwPullAllActiveChildOther.LastName} THEN
   {vwPullAllActiveChildOther.FirstName}
ELSE
   {vwPullAllActiveChildOther.FirstName} + " " + {vwPullAllActiveChildOther.LastName};[/b]
ELSE
0

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of vasto
vasto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What error are you getting in the formula?

mlmcc
FWIW, I'm also wondering what error you were getting.  Nulls do seem like the obvious suspect, but if they're not handled in a formula, it seems like you usually just get incorrect results, rather than an actual error.

 Also, you have 3 different table names in your first post.  The table name includes "Active" in the code, but "Arvie" (probably a typo) and "Archive" in the text.  Both "Active" and "Archive" make sense in the table name, so which table are you actually looking at?  Just checking.


 If you haven't already figured this out, you need to remove the [/ b] from the end of one of the lines in the code in vasto's last post.  You had tried to make some of the code bold, but formatting like that doesn't work in code blocks (they're specifically designed to present things without any formatting), so the bold tags were just left in the text.

 James