Solved

Crystal Report formula - loop, condition

Posted on 2003-11-05
7
482 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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