Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Concat multiple values of same field on 1 detail Post Reply Post New Topic
Author Message
jimbo79
Newbie
Newbie


Joined: 03 Aug 2011
Online Status: Offline
Posts: 4
Quote jimbo79 Replybullet Topic: Concat multiple values of same field on 1 detail
    Posted: 11 Aug 2011 at 1:06am
Table 1       Table 2
1               1      a
2               1      b
3               1      c

I want to concatenate a b c onto a single details line for the value in Table 1.

This is as far as I got but the array only ever returns 1 value and so the loop never works.


    Dim arrTestodes
    arrTestodes = array({Table2.Column2})

    Dim i
    Dim stringoftests
    i = 1

    Do while i <= ubound(arrTestodes)
        if i < 2 then
            stringoftests = totext(arrTestodes(i))
        else
            stringoftests = stringoftests + ", " + ToText(arrTestodes(i))
        end if
    i = i + 1
    Loop
    formula = stringoftests


Where am I going wrong?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 11 Aug 2011 at 3:22am
since when you join the tables, there is are still 3 rows in the resulting table that CR sees, and CR only reads 1 row at a time, it doesn't see that there are 3 related items (well not in the detail section)
 
you can concatenate if you put the output in a group footer, since CR will have read all 3 records by that time.  3 formulas are usually needed
1) header - reset
shared stringvar concat := ""
2) footer - display
shared stringvar concat;
mid(concat, 3)   //removes the leading comma and space
3) detail - increment
shared stringvar concat;
concat := concat + ", " + {table.field};
""   //hides the growing string
 
HTH
IP IP Logged
jimbo79
Newbie
Newbie


Joined: 03 Aug 2011
Online Status: Offline
Posts: 4
Quote jimbo79 Replybullet Posted: 11 Aug 2011 at 4:37am
Thanks very much for the respnse.

Please can you add a bit more meat to your answer, I'm not 100% on what I need to do.

Thanks

James :-)
IP IP Logged
jiangjiang
Newbie
Newbie


Joined: 14 Aug 2011
Online Status: Offline
Posts: 1
Quote jiangjiang Replybullet Posted: 14 Aug 2011 at 5:44pm
cheerful and most looking kid as one of the gang with all pals.Party Dresses uk If you're shopping with junior clothesin larger sizes then it could be prudent that you want flare jeans or bell-bottoms and it will indeed become a wise choice to have the kiddo appear voguish. Wedding Dresses storeAdditionally, make sure that you've got some black, as they may last 
IP IP Logged
Cassal Services
Newbie
Newbie
Avatar

Joined: 15 Aug 2011
Location: United States
Online Status: Offline
Posts: 2
Quote Cassal Services Replybullet Posted: 15 Aug 2011 at 3:03am

If your data is coming sorted with groupings, you can use the "NEXT" function in a formula.  

If NEXT{matching-field} = {matching-field} Then {OutputField}
 
The NEXT or PREVIOUS function allows you to look at the record just after or just before, and then make a decision to concatenate the next record into your output formula field.
IP IP Logged
GJUFFER
Newbie
Newbie


Joined: 04 Nov 2011
Online Status: Offline
Posts: 1
Quote GJUFFER Replybullet Posted: 04 Nov 2011 at 3:02pm
Suppose you have data that looks like this:

1     -     Rose
2     -     Violet
3     -     Rose
4     -     Tulip

Is there a way to concatenate the second column as shown above and also remove the duplicate strings?  My data source needs to be in sequential order, so suppress if duplicated is not an option.


Edited by GJUFFER - 04 Nov 2011 at 3:03pm
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.