Solved

Crystal Report formula - loop, condition

Posted on 2003-11-05
7
481 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now