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

Formula Problem

Status
Not open for further replies.

CrystalUser1

Programmer
Sep 16, 2004
138
US
Hi,

I am using crystal reports 8.5 and I wrote the following formula to display the concatenated employee name:

If there is a middle name, the formula displaying null. I am not sure if I have to " " values also.

If there is no middle name, then it is showing concatenated first name and last name.

Can anybody help me to solve why its not showing the concatenated name if there is a middle name?



if ((isnull({emp.emp_FNAME})) and (isnull({emp.emp_MNAME}))and (isnull({emp.emp_LNAME})))
then ""
else if isnull({emp.emp_MNAME})
then
{emp.emp_FNAME} +" "+{emp.emp_LNAME}
else if isnull({emp.emp_FNAME})
then {emp.emp_LNAME} +" "+ {emp.emp_MNAME}
else if isnull({emp.emp_LNAME})
then {emp.emp_FNAME} +" "+{emp.emp_MNAME}

Thanks in advance.
 
You might use:

iif((isnull({emp.emp_FNAME}),"",{emp.emp_FNAME}&" ")
&
iif((isnull({emp.emp_MNAME}),"",{emp.emp_MNAME}&" ")
&
iif((isnull({emp.emp_LNAME}),"",{emp.emp_LNAME})

-k
 
I used the above formula replacing my entire formula, but its showing the names with all the first,last and middle names. its not showing the names with no middle names and has first name and last name.

thanks
 
Sorry, had some typos there, try:

stringvar lname:={emp.emp_LNAME};
stringvar fname:={emp.emp_FNAME};
stringvar mname:={emp.emp_MNAME};
iif(trim(fname)="","",fname&" ")
&
iif(trim(mname)="","",mname&" ")
&
iif(trim(lname)="","",lname)

-k
 
Thank you Synapsevampire, but having the same problem. showing only names with all first name, last name and middle names. not showing if it has only first,last or middle or any combination.

thanks
 
Here's what I use with my CR 8.5 reports

Code:
//Last, First Middle from MASTER_NAMES
stringvar n;

if isnull({MASTER_NAMES.LNAME}) then
    n := n
else
    n := {MASTER_NAMES.LNAME};
if isnull({MASTER_NAMES.FNAME}) then
    n := n
else
    n := n & ", " & {MASTER_NAMES.FNAME};
if isnull({MASTER_NAMES.MNAME}) then
    n := n
else 
    n := n & " " & {MASTER_NAMES.MNAME};
n

-LW
 
Hi,

Thanks for all your help. I created a sql expression to get the exact results. its working good.

{fn CONCAT({fn CONCAT({fn CONCAT({fn RTRIM(emp."emp_LNAME")},', ' )}, {fn LTRIM({fn CONCAT({fn RTRIM(emp."emp_FNAME")},' ' )})})},emp."emp_MNAME" )}

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top