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!

Suppress part of a string

Status
Not open for further replies.

jonbarr

MIS
Jun 20, 2003
66
0
0
NZ
CR V8.0

I want to be able to suppress the first character in a string.

I have used a formula to give me a list of names which are a combination of letters and numbers.
I am grouping on this formula.

Now I want to sort these names in a specified order.

If I use the "Specified Order" function, and choose 'is equal to', the drop-down menu is blank.
Rather than type in each formula result and have a problem if the formula is changed, which it sometimes is, I thought that a quick and easy way would be to insert a letter at the beginning of each name in the order I require -
e.g. aName 1, bName 2, cName 3 etc.
and then suppress the left character of the string.
This has the desired effect of sorting in my specified order, but I haven't found a way to suppress the first letter.

In the Format Editor/Common/Suppress formula box, I have tried " left({formula field},1)" but get the message "the formula result must be a boolean".

Can anybody help, please ?

 
Try customizing the group name field like this:

Get into the group options dialog.
Continue to group on your formula.
Under Options, select the property "Custom Group Name field"
Under Choose an Existing Field, select the original field in the drop down box.
Click OK and Test

~Brian
 
Thanks for your reply Brian.

Unfortunately, the existing fields do not include my formula. I need to be able to sort on my formula name, not the name from an existing field, and then suppress the first character to show only the required display name.
 
The left function would not do what you want anyway. You want to suppress the 1st character, not get it. I don't have Crystal in front of me, but I think there is a mid function and a length function. You need to use a combination of the two.

Something like this:

mid({FieldName},2,lenght({FieldName})-1)

I don't think those are the actual names of the functions, but you should be able to look it up from here.

Hope this helps.
 
Create a 2nd formula:

right({@FirstFormula},Length({@FirstFormula})-1)

Show this formula and sort on the first one.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
bdreed had the simplest solution. If you are grouping on your formula, then you would go to report->change group expert->options->customize group name and choose the actual field name {table.name}, instead of your formula. The formula would still be used for grouping, while the field would be used for display.

Another approach would be to remove the groupname (your formula) from your group header, and add the following formula:

mid({@yourformula},2)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top