Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

7.06 Printing Checkboxes

Printing Checkboxes

There are many ways to display a Boolean constant. You can display the words Yes/No or True/False. Right-click on the field and select Format. The dialog box displays a drop-down box that lets you select how you want the data to be displayed (Yes/No, True/False, etc.).

You can also display Boolean values as a checkbox, but this requires a little more creativity. Crystal Reports doesn’t have a built-in method for displaying checkboxes. You have to use the control characters in the Wingdings font. There are a variety of interesting characters in the Wingdings font. But five of them can be use for displaying checkboxes. Figure 7-10 shows some of the Wingdings characters available.



Figure 7-10. Wingdings control characters.

Find the character you want to display and click on it. At the bottom you will see the Character Code value that you need to print. Write down this number. The character that you may not find right away is the empty checkbox. If you scroll up you’ll see that it is code 168.

To display a checkbox on the report, create a new formula field and insert the following formula.

If {Table.Field} = True Then
'Display checked box
Formula = Chr(254)
Else
'Display empty box
Formula = Chr(168)
End If

This formula tests a field to see if it is True. If so, it returns the control character 254 (a checked box). If it is false, it returns the control character 168 (an empty box). Save the formula and close the Formula Expert dialog box.

Drag this formula from the Field Explorer onto the report. Finally, change the font to be Wingdings by right-clicking on the field and selecting Format. Click on the Font tab and use the dropdown box to select the Wingdings font. Save the report and run it to see the checkbox displayed.