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

Grouping 4 formula field results into one field 1

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
I have 4 formula fields that return text strings.

When I previously had two of them I grouped them into the same field, but first checking the existence of text in the field as follows:


if {@field1}="No Exception" then "<b>1.</B>"+{@field2}
else if {@field2} = "No Exception" then "<b>1.</B>"+{@field1}
else "<b>1.</b>"+{@field1}+
"<br><b>2.</B>"+{@field2}

as you can see if either of the formula fields have the text "No Exception" they are not displayed, and the remaining formula field (if any) will be positioned as number 1.


I now have 4 formula fields, each using the same principal, but I am getting into a complete mess when trying to apply the above principal to 4 values.

the fields are as above: {@field1}, {@field2}, {@field3},{@field4}
can anyone help me use all 4 fields in the above formula?
If any of the 4 fields have the value "No Exception" then they should not be displayed, but the remaining fields when grouped should be preceeded by sequetional number labels (1, 2, 3 etc)

many thanks,





Matt
London (UK)
 
Try the following:

whileprintingrecords;
numbervar counter := 0;
stringvar array x := [{@field1},{@field2},{@field3},{@field4}];
numbervar y := ubound(x);
stringvar result := "";

for counter := 1 to y do(
if x[counter] <> "2" then result := result + "<b>"+totext(counter,0,"") + ". "+"</b>" + x[counter] + "; ");
result;

Be sure to format the formula for HTML interpretation (format field->paragraph formatting->text interpretation->HTML).

I didn't know how you wanted to separate the numbered items, so added in a semi-colon. You could replace "; " with chr(13) if you would like a return after each item. Then you would also need to format the formula to "Can Grow" (format field->common->can grow).

-LB
 
Oops, that's not working quite right. Let me get back to you with a fix (I hope).

-LB
 
Accidentally left in a test field, too. Here is something that I believe works:

whileprintingrecords;
numbervar counter := 0;
stringvar array x := [{@field1},{@field2},{@field3},{@field4}];
numbervar y := ubound(x);
stringvar result := "";
numbervar counterx := 0;

for counter := 1 to y do(
if x[counter] <> "No Exception" then
(counterx := counterx + 1;
result := result + "<b>"+totext(counterx,0,"") + ". "+"</b>" + x[counter] + "; "));
result;

-LB
 
wow, thanks for that.
one question, where would I put a <br> in the formula to have a carriage return after each fiel?



Matt
London (UK)
 
oops, sorry, didn't see that bit on your first reply!

thanks again LB - that is fantastic!

Matt
London (UK)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top