• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Formatting a portion of a text string within a formula

I'm using Crystal v9 against Excel data.  One of the report fields is a large body of text that contains a formula.  Based on an Excel field, the formula will either say, "not enrolled...." or it will say, "enrolled with {Excel field} plan with {Excel field} coverage.  The formula is shown below.

Is there a way to make just the portion of the formula that comes from the Excel fields bold or set to a different color?


if isnull ({Sheet1_.Med Type}) then
"not enrolled in a medical insurance plan."
Else
"enrolled in the " + CStr ({Sheet1_.Med Type}) + " plan and with " + CStr ({Sheet1_.Med Cov}) + " coverage."
0
anordquist
Asked:
anordquist
  • 4
  • 4
  • 2
1 Solution
 
bdreed35Commented:
Try this:

Change the formula to this:

if isnull ({Sheet1_.Med Type}) then
"<html>not enrolled in a medical insurance plan.</html>"
Else
"<html>enrolled in the <b>" + CStr ({Sheet1_.Med Type},"0") + "</b> plan and with <b>" + CStr ({Sheet1_.Med Cov},"0") + "</b> coverage.</html>"

Then right click the field as it is on the report, and choose Format Field.
Click the paragraph tab, and change the Text Interpretation from None to HTML

0
 
DataSenserCommented:
Another idea woudl be to create 2 text boxes, one for the enrolled message and one for not enrolled.  You can control the format of the individual elements of a text box.  In the properties of the boxes, choose to conditionally suppress the enrolled box using your isnull() and vice-versa for the not enrolled box.

HTH,
DS
0
 
anordquistAuthor Commented:
The solution posted by bdreed35 isn't working as I'd like under Crystal v9.  The html tags aren't being interpreted (maybe there's a flag that needs setting somewhere?), so it shows up as "<html> enrolled in the <b> YourPlanName /<b> and with <b> YourCoverageAmount /<b> coverage.

Also had to pull out the second parameter in the Cstr commands.

I've contemplated the solution posted by DataSenser, but it's not the solution I'm looking for.  I only want to bold a portion of the string, not the entire string.  I think bdreed35 understands what I'm trying to do.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DataSenserCommented:
Just a small point, but you can bold only a portion of a string in a text box, that's what I meant by controlling the format of the individual elements of a text box.  Good luck.
0
 
bdreed35Commented:
anorquist:

Did you folow the last part of my first post:

Then right click the field as it is on the report, and choose Format Field.
Click the paragraph tab, and change the Text Interpretation from None to HTML

You need to do this so that it is interpreted as HTML
0
 
anordquistAuthor Commented:
My version of Crystal (9) has the following main fields in the Format Field\Paragraph tab:

Indentations
Spacing
Reading Order
Horizontal Alignment

What version allows Text Interpretation?
0
 
anordquistAuthor Commented:
I took another look at the form.   I'm working with a text object that includes a formula.  A test case I put together with just a text object doesn't show the Text Interpretation choice that bereed35 describes.  However, that choice does exist for a database field.
Time for more tweaking.
0
 
bdreed35Commented:
Every version as far as back as 8.5, that I know of.

I don't get horizontal alignment as an option.  Where are you using this formula?
0
 
bdreed35Commented:
Ok, gotcha now.  
Either put the formula on the report by itself and you will get the text interpretation option, or in design mode, double click the text object until the cursor appears inside of it, then click on the formula field and right click it.
Choose Format {@Formula Name} and then under the Paragraph tab you will have Text Interpretation.
0
 
anordquistAuthor Commented:
bdreed35 hit the nail on the head.

I didn't know that you could select a formula inside of a text box and format it.  Live and learn.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now