Printing check marks and other symbols from formulas

Friday 31 August 2007 @ 4:01 pm

Maybe instead of printing “YES” and “NO” in a report column you want to print a check box symbol – with or without the check mark. All you need to do this is the WingDing font, which is on most PCs, and a formula like the following:

If {Order.Shipped} = “T”
then Chr(254)
else Chr(168)

Place this formula on your report and assign it the WingDing font. You will see a box for each record, with check marks only on the shipped records (or whatever your condition). You can also use other graphic fonts like Webdings, Symbol, Map Symbols, Vacation MT, etc. This gives you hundreds of symbols to pick from, as long as you know the font and the ASCII number of the symbol that you want. And even if you don’t know the ASCII number you can look it up.

To see all the symbols you have available, open up the windows “Character Map” program. This is usually in your start menu somewhere around “Programs->Accessories->System Tools”. If not there, you can search for Charmap.exe and run it. This little program shows all of your fonts and the symbols that you have available in each. Here is an example of transferring a symbol to your report without knowing the number.

1) In CharMap, select the “symbol” font. Locate the bold heart in the lower right.
2) Single-click on it to magnify it.
3) Click the “Select” then the “Copy” buttons at the bottom of the window.
4) Switch to your report and open one of your If-Then-Else formulas that is character.
5) Paste the symbol in as the THEN or ELSE value (it will be copyright symbol for now).
6) Put quotes around the copyright symbol and save the formula.
7) Place the formula on the report, and select the “Symbol” font.

It should print bold hearts on some records when you preview the report.

I prefer to use the CHR function, as in my original example. But, this requires the extra step of finding the ASCII code for the symbol. One way is to paste your symbol from the character map into a formula with the ASC() function. This way Crystal will display ASCII number for you. If you create the following formula:

ASC(‘_’)

and replace the _ with a symbol like the copyright symbol, Crystal will display the ASCII value for that symbol, like169 for the copyright symbol. Therefore, the following formula:

CHR(169)

would give you a heart, or a copyright symbol, or possibly something else, based on the font you select.

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)







Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server