Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: concatenate names in crystal Post Reply Post New Topic
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: concatenate names in crystal
     Posted: 24 Dec 2012 at 2:21am
Hello, I'm trying to figure out how to concatenate a name field in crystal to show "lastName, firstName" as 1 field. I tried {lastName} + "," + {firstName} but that isn't working.


Also, I can't figure out how to zero fill a field in crystal. For example if I have the department id of 59 and the client wants the field zero filled to 9 spaces it would show 000000059.

Any help that anyone can give would be amazing! Thank you in advance!
IP IP Logged
cheenu_vasan
Newbie
Newbie
Avatar

Joined: 06 Apr 2011
Location: India
Online Status: Offline
Posts: 16
Quote cheenu_vasan Replybullet Posted: 24 Dec 2012 at 3:10am
For concatenating two strings you can use the "&" instead of "+".

For the format numbers, you can write a formula in place of the number field and whose defn. will look like below steps:

1. Store the number value in variable
2. Get the Len of that value (Use Len func)
3. Write a switch case

If Len = 1 then concatenate "00000000" & number
If Len = 2 then concatenate "0000000" & number
If Len = 3 then concatenate "000000" & number
else
........

Hope these will solve your query...thks
Thanks & Regards
Srinivasan B
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 24 Dec 2012 at 3:45am
so for the name it should look like this?

//5 Employee Name "Lastname, Firstname"
{EInfo.lastName} & "," & {EInfo.firstName} + "," +

as far as the len i'm not sure that i fully get it. i'm still pretty new to crystal and all that it can do. i was thinking that maybe i could do something similar to this

//8 Department 6 digits zero fill
Left({ELaborDist.cc1}, 6) + "," +

to show the department number and fill the remaining spaces with zeros to go 6 spaces to the left.

thoughts?
IP IP Logged
cheenu_vasan
Newbie
Newbie
Avatar

Joined: 06 Apr 2011
Location: India
Online Status: Offline
Posts: 16
Quote cheenu_vasan Replybullet Posted: 24 Dec 2012 at 4:29am
{EInfo.lastName} & "," & {EInfo.firstName} will work for you. Did you gave a try?

For the  select/switch case stmt you can use something like this with logic as above in my first reply:

Select {fieldname}
Case  1 :
"A"
Case  0 :
"B"
Case  1 :
"C"
Case  3 :
"Closed"
Case  4 :
"D"
Default :
"default"

Len will give you the number of character in the string so based on this you will be adding the zeros in the above case stmt.


Edited by cheenu_vasan - 24 Dec 2012 at 4:30am
Thanks & Regards
Srinivasan B
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum