Solved

Crystal Report formula - loop, condition

Posted on 2003-11-05
7
484 Views
Last Modified: 2008-03-10
Tabel1: ReportID(PK), OrderID (one report only has one order)
Tabel2: OrderID, ItemID (no primary key)
Tabel3: ItemID(PK), Itemname  

I need a formula to print all the itemnames for a certain ReportID in one field, so this field can appear in report heading. Can anyone please help? Thanks.
0
Comment
Question by:jessica00
  • 3
  • 2
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 9692778
So is your report only reporting on one selected ReportID?

Pete
0
 
LVL 77

Expert Comment

by:peter57r
ID: 9692845
Assuming you are only reporting one ReportID in a report.

Create a formula fDetail:

global stringvar vItemnames;
vItemnames := vItemnames & ", " & {ItemId.ItemName};

This goes into the detail line but can be suppressed.

Create a formuls fRH:

Whileprintingrecords;
global stringvar vItemnames;
vItemnames

This goes into the report header and needs to be formatted as 'Can Grow'.


Pete

0
 

Author Comment

by:jessica00
ID: 9697701
Yes, one selected ReportID.
I tried your suggestion, and get duplicated itemnames, and my other report details become duplicated as well.
 
Forgot to say, my report has two group sections. I have another two tables to hold printed details.
Table 4: Group1_name(PK), ReportID
Table 5: Group2_name, Group1_name - no PK in this table

Any more hints you can give me? Thanks
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 77

Expert Comment

by:peter57r
ID: 9700257
'get duplicated itemnames, and my other report details become duplicated as well

I can sort out the duplicated itemnames but I don't know what you mean by 'other report details'.
Nothing I am doing is affecting the rest of the report.

Pete

The formula to go into the detail line is:

global stringvar array itemnames1;
global numbervar x;
numbervar y;
numbervar z;
z:=0;
for y:=1 to x do
(
if itemnames1[y] = {ItemId.ItemName} then
(
z:=1
)
else
// do nothing
(
y:=y
);
);

if z=0 then
(x:=x+1;
redim preserve itemnames1[x];
itemnames1[x]:= {ItemId.ItemName};
0
)
else
(
x:=x;
0
);



The formula to go into the Report Header is :
whileprintingrecords;
global stringvar array itemnames1;
global numbervar x;
local stringvar result;
local numbervar xx;

result:= itemnames1[1];
for xx:=2 to x do
result:= result & chr(13) & itemnames1[xx];

result



0
 

Author Comment

by:jessica00
ID: 9726457
I sorted out with a subreport
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11860312
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question