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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array problems

Status
Not open for further replies.

Mavors

Programmer
Aug 28, 2000
43
US
Hello all. I've been working on this one for a couple days off and on and am stumped to say the least. I am creating a report that has two groups. The first one is on a specific client then on the individual contracts for each client. My problem lies in that the detail info come duplicated due to there being multiple agents for the one contract. As you might guess they don't want the information duplicated to show all the agents, but instead would like them listed horizontally at the end of each contract. So I moved the detail to the contract to the group header of the contract and am trying to collect the agents into an array that I can work with in the group footer. I keep getting the error that the subscript must be between 1 and the max for the array. Alsot they have said that there will be a max of 6 agents but that they may be duplicated a few times each. Another note is that some of my fomulas are boolean for some reason so I had to use the ToText function. Man I wish I knew more about crystal reports.
Here are the formulas that I am attempting:
In the detail:

//Formula @AgentsArray
//Put all the agents into an array
StringVar Array Agents[100];
NumberVar AgentNum;
AgentNum := AgentNum + 1;
Agents[AgentNum] := {ClientContractListingByAmount_ttx.AgentCode};

In the group footer:

//Formula @Agent1
StringVar Array Agents;
NumberVar AgentNum;
IF AgentNum > 0 Then
Agents[1];

//Formula @Agent2
EvaluateAfter ({@Agent1});
StringVar Array Agents;
NumberVar AgentNum;
Local NumberVar i;
For i := 1 to AgentNum Do
(
IF Agents <> {@Agent1} Then
(
Agents;
Exit For
)
);

//Formula @Agent3
EvaluateAfter ({@Agent2});
StringVar Array Agents;
NumberVar AgentNum;
Local NumberVar i;
For i := 1 to AgentNum Do
(
IF Agents <> {@Agent1} AND Agents <> ToText({@Agent2}) Then
(
Agents;
Exit For
)
);

//Formula @Agent4
EvaluateAfter ({@Agent3});
StringVar Array Agents;
NumberVar AgentNum;
Local NumberVar i;
For i := 1 to AgentNum Do
(
IF Agents <> {@Agent1} AND Agents <> ToText({@Agent2}) AND
Agents <> ToText({@Agent3}) Then
(
Agents;
Exit For
)
);

-----I would post the next two, but they are along the same lines with just updated IF to include a check for duplication. Sorry for such a big post but I'm dragging here and could use any aid anyone can send forth.

My thanx, [sig][/sig]
 
Darn it...the post messed up some and didn't place everything that is in the formulas...guess I should have read the editing tips better.

When you see a Agents used in the formulas of the footer alone it really has a
Code:
[i]
at the end of it.

My thanx,

Mavors
ericd@stevensconcepts.com [sig][/sig]
 
Mavors,

If I understand correctly you want to take a vertical list of agents, unduplicate it, and turn it into horizontal list that prints at the end of a group.

You are definitely doing it the hard way trying to use an array. All you need to use is a running total that concatenates the strings together.

There is a FAQ on running totals that shows the &quot;three formula&quot; technique. Usually this is used with numbers but it can also be used with text.

Use the following formula to see if the current agent is in the list already, and if not add him:

WhilePrintingRecords;
StringVar test;
if {yourtable.agent} in test
then test:=test
else test:= test +', ' + {yourtable.agent}

This field should be on the detail band (suppressed). It will keep building until it is reset. Use the following to reset it at the beginning of each client:

WhilePrintingRecords;
StringVar test;
test:= ''

Display it at the end of each client with the following formula on the group footer:

WhilePrintingRecords;
StringVar test;
test [3 to length (test)]

The last line eliminates the &quot;, &quot; from the beginning. There are other approaches that you can use, but this gives you the basic idea.
[sig]<p>Ken Hamady<br><a href=mailto:ken@kenhamady.com>ken@kenhamady.com</a><br><a href= Reports Taining by Ken Hamady</a><br>[/sig]
 
Thanx a lot Ken. I never even thought of going about it that way. I am still getting an error though. Telling me that the string can only be 254 characters in length, but I think I can handle this one. My thanx for some sound advice.

Mavors [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top