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

Dynamically create array using fields from table 1

Status
Not open for further replies.

morechocolate

Technical User
Apr 5, 2001
225
US
I have something that looks like this

GH1 12345
Detail Apple 12345
Detail Apple 12345
Detail Pear 12345
Detail Orange 12345

GH1 45688
Detail Peach 45688
Detail Plum 45688


In GH1 I want to have

12345 Apple,Pear,Orange
45688 Peach,Plum

Is that possible?

I tried doing a while loop to fill an array. However, the array was not getting populated. I believe the array was not getting populated because I got an error (A subscript must be between 1 and size of the array.)I also was not sure how to reset the array one it got to a new GH1.

I wanted to dynamically build the array using the fields in the table (example fruits above)rather than filling the array with possible values b/c at any time we could add values or change values.

stringVar array PropertyType;
numberVar n := 1;
numberVar cnt;
stringVar strPropertyType;

While GroupName ({INSR_RISK;1.PI_INV_ID}) = {INSR_RISK;1.PI_INV_ID} Do
(
if {INSR_RISK;1.PR_PRTY_TYP} = next({INSR_RISK;1.PR_PRTY_TYP}) then
PropertyType[n] := {INSR_RISK;1.PR_PRTY_TYP};
n := n + 1;
);

For cnt := 1 to UBound(PropertyType) Do
(
if PropertyType[cnt] = {INSR_RISK;1.PR_PRTY_TYP} then
if (cnt < UBound(PropertyType) and UBound(PropertyType) <> 0) then
strPropertyType := strPropertyType + PropertyType[cnt] & &quot;, &quot;
else
strPropertyType := strPropertyType + PropertyType[cnt]
);
strPropertyType

Any ideas?

Thanks

mc
 
Ro - Thanks for the link.

Without having read the document, I was also thinking that I may be making this more difficult than I need to. I was thinking I could get what I wanting using running totals.

However, I may run into a problem when I have something like:

GH1 12345
Detail Apple 12345 2 100
Detail Apple 12345 4 200
Detail Pear 12345 5 150
Detail Orange 12345 7 50
Detail Apple 12345 8 130

GH1 45688
Detail Peach 45688 1 100
Detail Plum 45688 3 300
Detail Peach 45688 5 400

In addition to the group, I have a feild that I sort so that I can properly do running totals on the amount field. Since I already have that sorting I cannot not sore on the field that I need to display as Apple,Pear, Orange. Thus, the running total would yeild Apple,Pear,Orange,Apple.

The other issue, is I would not be able to but the information in the Group Header. With the running total I would have to display it in the Group Footer.

Hopefully the document will be helpful.

Thanks again

mc (yum yum)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top