Using bar code functions and fonts in Crystal Reports

APPENDIX A lists each bar code type with the function and bar code font to use in Crystal Reports. For example, to print Code 39 bar codes lookup Code 39 in the Bar code type column and you will find;

Bar code type
Function to use
Font to use
Font size Format options
Code 39 BarcodeCODE39( "C39-0.B", ) CIA Code 39 14+

1. To add a bar code field to your report, choose menu Insert | Formula Field.

2. Enter any formula name (e.g. My Formula) and choose the Add button.

3. Double-click in the Function list to insert the bar code function in to the formula;

BarcodeCODE39("C39-0.B", )

4. Double-click in the Field list to insert the field which you want to print as a bar code;

BarcodeCODE39("C39-0.B", {table.FIELD})

If the field is not a character field (i.e. if it is a number, currency or date) use a function to convert it to a string. For example, if your field is a number you can print a bar code like this;

BarcodeCODE39("C39-0.B", ToText({table.FIELD}))

The following function is similar to ToText(x) but it also adds leading zeros;

BarcodeTextZeroPad(number, width, #places) 

Useful built-in to Crystal Reports functions for converting numeric values to strings are;

ToText(x)
ToText(x, #places)

You may also need to use these functions for strings;

TrimRight(x)
TrimLeft(x)
UpperCase(x)

Dates can be converted to strings like; 1997/01/31 or 2001/01/31;

ToText(Year(Date)) + "/" + ToText(Month(Date)) + "/" + ToText(Day(Date)

Dates can also be converting to strings like; 19970131 or 20010131. This produces shorter bar code and also allows you to use bar codes that support characters 0-9 only;

BarcodeINTERLEAVED2OF5("ITF-0.B", ToText(Year(Date)) + ToText(Month(Date)) + ToText(Day(Date))

5. After entering your formula, choose the Accept button and place the field on your report.

6. Select the field in your report and choose the bar code font and point size.

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.