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?
jwebster77Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vastoCommented:
Check the value of the field for nulls

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

default value
0
jwebster77Author Commented:
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

0
vastoCommented:
Try this:

if not isnull({vwPullAllActiveChildOther.LastName}) then
(
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
""

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlmccCommented:
What error are you getting in the formula?

mlmcc
0
James0628Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.