Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Crystal Report formula - loop, condition

Posted on 2003-11-05
7
Medium Priority
?
497 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
6 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

783 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