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!

Rearranging a string field

Status
Not open for further replies.

auylox

Technical User
Feb 7, 2007
20
CA
Hi there,

I am trying to rearrange a string field that is in the following format:

LastName, FirstName; LastName, FirstName; ...

Where there is no limit on the number of names.

To show:

FirstName LastName, FirstName LastName, ...

Is this possible?

Thanks for any help.
 
Try:

whileprintingrecords;
stringvar output:="";
stringavar array MyField:=split({table.field},";");
numbervar x;
for x := 1 to ubound(MyField) do(
outout:=output + trim(split(MyField,",")[2]) & " " & TRIM(split(MyField,",")[1]) & ", ";
);
Left(output,len(output)-2)

Replace table.field with your field

-k
 
Thanks for your quick reply!

However, when I try it out, I get an error message that says that my field, {VW_CATALOGUE.MAKER}, following the ubound function, needs to be an array .

The following is what I input:

whileprintingrecords;
stringvar output:="";
stringvar array Maker:=split({VW_CATALOGUE.MAKER},"; ");
numbervar x;
for x := 1 to ubound(makearray({VW_CATALOGUE.MAKER})) do(
output:=output + trim(split({VW_CATALOGUE.MAKER},", ")[2]) & " " & TRIM(split({VW_CATALOGUE.MAKER},", ")[1]) & ", ";
);
Left(output,len(output)-2)

Thanks again
 
Well that's not my formula, but mine needed work...


whileprintingrecords;
stringvar output:="";
stringvar array MyField:=split({VW_CATALOGUE.MAKER},";");
numbervar x;
for x := 1 to ubound(MyField) do(
output:= output + split(MyField[x],",")[2] +" " +split(MyField[x],",")[1] +", "
);
Left(output,len(output)-2)

-k
 
Thanks, that worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top