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

Sorting a String field....

Status
Not open for further replies.

scan2k

MIS
Apr 1, 2003
20
0
0
US
Hello, hope one or more of you can shed some light. I am using Crystal 8.5 and have a string variable I created to show parameters entered in a report. For example if the user enters, DB, AC, CD etc. then this formula will print the parameters entered at the top of the report. What I'd like to be able to do is have this list sorted alphabetically. Here is the code I'm using to concatenate the strings together...the results desired would be AC, CD, DB. Any help is appreciated.

rem MULTIPLE PARAMETERS TO PRINT AT THE TOP OF A REPORT

rem Declare a string variable x
WhilePrintingRecords:
shared b as string:
dim i as number:
i = 1:

rem Loop for the number of elements in the parameter
rem where 'b' is assigned to itself plus parameter 'i'
rem and then increment i, on last loop don't add "," to end of parameter list
for i = 1 to count({?Category Code})
if i <= (count({?Category Code})-1) then
b = b + {?Category Code}(i) + ", "
else
b = b + {?Category Code}(i)
end if
Next

formula = ucase(b)

rem IF * is entered then print (All Codes)
if formula = "*" then
formula = "(All Codes)"
end if

rem MULTIPLE PARAMETERS TO PRINT AT THE TOP OF A REPORT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top