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

Displaying a string field with special formatting 1

Status
Not open for further replies.

dkloepfer

Technical User
Oct 31, 2003
5
US
I have a string field in a database that displays values such as "014086001341" I wish to always have the last four digits to be inserted into a box or other special formatting such as being in Bold or underlined


 
Right (str, length)
Basic and Crystal syntax.

Arguments
str is a text string.
length is a whole number indicating the number of characters to be extracted from str.
Returns
String value

Action
Extracts the given number of text characters from the right side of the specified string.

Typical uses
Use this function to obtain just the right part of a string. For instance, use it to obtain the last four digits of social security numbers stored in a field.

Examples
The following examples are applicable to both Basic and Crystal syntax:

Right("abcdefg", 3)

Returns "efg".

Right({table.SSNUM}, 4)

Returns the last 4 digits of the social security number as a String.

 
Thank You, however I wish to have the whole number displayed , with the last four digits in a box or in bold print.
 
1) Break the string into two parts using the right and left functions.
Forumula1
StringVar a = Right({yourField}, 4);

Formula2
StringVar a = Left({yourField}, 4); //assuming your number is 8 chars long.

2) In design mode, put a text field into your report. Type this text into the text field: "left + right"

3) Place the two formulas you created in step1 on the page.
4) Make the formula1 bold.
4) Drag formula1 INTO the text field you created and place it on the right side of the plus(+) sign.
5) Delete the text "right" from that text field.
6) Drag formula2 INTO the text field you created and place it on the left side of the plus(+) sign.
7) Delete the text "left" from that text field.
8) Delete the plus(+) sign and any remaining spaces from the text field.

What you will be left with is a text field that sticks two formula values together. You format the formula field before you drag it into the text field and the formatting will hold.

I don't believe that you will be able to format the separate parts once they are combined into the field.
 
Well, you could just drag both formulas into a text box, and select the one you want bolded and bold it.

You can also create a formula like this:

left({table.field},8) + "<b>"+right({table.field},4})+"</b>"

Then highlight the formula->right click->format->paragraph->text interpretation->HTML text.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top