Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: display items/records horizontally Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: display items/records horizontally
    Posted: 19 Jan 2009 at 9:05pm
I have a same problme reported on this site: I want to disply items from one field detail section horizontally:
 
A, B, C
 
instead of vertically
A,
B,
C
 
while other records are shown vertically ?
 
Thanks in advance...

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 20 Jan 2009 at 6:24am

I haven't had this requirement, but I don't think it is doable. 

You are wanting to print multiple data rows on 1 line, and Crystal is reading 1 data row per line, so mixing directions doesn't work too well.
 
As I am typing, the only solution that comes to mind is to use a formula with a shared variable and display it in either the header or the footer of a grouping.  As Crystal reads each data record, it could append to the shared variable, and by the end of the section, Crystal would have created your horizontal display.  Just remember to reset it when the group changes in such a way that you don't remove your data before you display it.
 
Hope this helps.
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 20 Jan 2009 at 2:00pm
thanks for your advice.
 
I have created three formulae following examples obtained from a Crystal Reprot web site(Ken Hamady).
 

In the report group header:

    WhilePrintingRecords;
    StringVar chain := '';
    NumberVar ChCnt := 1

In the detail section: ( suppressed when report runs)

WhilePrintingRecords;
    StringVar Item:= {Table.field};
    StringVar Chain;
    NumberVar ChCnt;

    if ChCnt = 1
    then (ChCnt:= 2; chain := Item)
    else
    if Length(Chain) + Length(Item) > 254 

    then Chain := Chain else
    chain := chain + ', ' + Item

In the report group footer:

WhilePrintingRecords;
    StringVar Chain


when my report runs, I found that data on one line repeating:
A, A, A, B, B, B, C, C,C
 
I can't figure out where was incorrect in the formula. Could you give my further advice or direction
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 21 Jan 2009 at 6:25am
ok, the code is appending every detail record in your group, so there must be multiple records there.  If you unsuppress the the details, do the number of lines match?  If A, B, C is unique, or you want it to be unique, you could try and catch the duplicates before adding by using instr...
if instr(Chain, item) = 0 then().
 
Hope this helps
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 21 Jan 2009 at 10:04pm
Thanks, lockwelle,
Also, A, B, C is unique, I do want to catch the duplicate before adding into the "chain". There are situatiions where there might not be any value or only one value. How do I do with these?
where should I put the line of
if instr(Chain, item) = 0 then().
Thanks for your further advices
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Jan 2009 at 6:22am
I would insert it here:
 
  if ChCnt = 1
    then (ChCnt:= 2; chain := Item)
    else 
if instr(Chain, Item) = 0 then
    if Length(Chain) + Length(Item) > 254 

    then Chain := Chain else
    chain := chain + ', ' + Item

IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 22 Jan 2009 at 2:18pm
Yes, it works! It removes duplicates.
Thanks very much lockwelle!
 
John
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.