Solved

Crystal Report formula - loop, condition

Posted on 2003-11-05
7
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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. …
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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