Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I stopping iteration in the report?

Status
Not open for further replies.

warning99

Programmer
Nov 5, 2007
53
0
0
SA
Hi,,

I create report as form. The Report contain this rows:

Employee No:
Employee Name:
Employee grade:
Employee Job Title:
Employee Qualifications:

Ok? Let Toni has tow qualifications. And we want print this report:

Employee No: 123
Employee Name: Toni
Employee grade: 7
Employee Job Title: Manager
Employee Qualifications: Engineering

Employee No: 123
Employee Name: Toni
Employee grade: 7
Employee Job Title: Manager
Employee Qualifications: MBA


Here the problem! I want create formula for qualification to be like this:

Employee No: 123
Employee Name: Toni
Employee grade: 7
Employee Job Title: Manager
Employee Qualifications: Engineering, MBA
 
You need to group on Employee No. Insert > Group and choose a field. You can then move the record details to group footer, and suppress the detail line. (Right-click on the section and choose Format Section.)

Finally you'll need to accumulate the qualifications. If there are a limited number, say half a dozen, you might use a running total to determine if that employee has it, and then use formula fields to build up the test.

If there are a lot of possibilities, you will need to accumulate values. Try adapting something I wrote to collect postcodes:
Code:
// Accumulate using a formula field (suppressed) in the detail line.  Allow for nulls and blanks.
whileprintingrecords;
if not isnull({Recc.Postcode}) and {Recc.Postcode} <> " "
then stringvar pst := pst + {Recc.Postcode} +", "
else if length(pst) = 0 
then stringvar pst := pst + "Excluding blanks; "
else stringvar pst := pst
Code:
// Show in using a formula field in the group footer.
whileprintingrecords;
stringvar pst;
left(pst,len(pst)-2)
Code:
//  Clear using a formula field using in the group header.
whileprintingrecords;
stringvar pst := "";




[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Madawc

I did first step. But I can not write the code. Please see:

whileprintingrecords;
if not isnull({Qualifications.Description}) and {Qualifications.Description} <> " "
then stringvar pst := pst + {Qualifications.Description} +", "
else if length(pst) = 0
then stringvar pst := pst + "Excluding blanks; "
else stringvar pst := pst

but I don't know what is pst. And this code show now only one qualification.

Thanks.

 
pst was just Madawc's name for the string variable. You could simplify this a bit, and just use this for {@accumulate}:
whileprintingrecords;
stringvar pst;
pst := pst + {Qualifications.Description} + ", ";

Then change the display formula in the group footer to:
whileprintingrecords;
stringvar pst;
if len(pst) > 2 then
left(pst,len(pst)-2)

Be sure to also add the reset formula to the group header.

-LB
 
New problem !!

now when i try run the report. The Report show this message:
a string can be at most 254 characters long.


note:
I insert one employee as parameter. and when I remove the suppress from details line. The employee no print 20 times.
 
Make sure you still have the reset formula in the group header for employee. Also change {@accum} to the following formula:

{@accumulate}:
whileprintingrecords;
stringvar pst;
if instr(pst,{Qualifications.Description}) = 0 then
pst := pst + {Qualifications.Description} + ", ";

-LB
 
It work now. Thank you man :))

if you have time... can you explain me how this code work?
 
The "instr(pst,field) = 0" line checks to see if the description has already been added to the variable, and then only adds it if it is not there. Instr(field, value to check) returns a number that represents the position of the value in the string. If it is 0, it is not in the string.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top