Create Code 128 Barcodes in Crystal Reports

Step 1. Add a new formula

  • In the Field Explorer, right click Formula Fields and click New...
Add a new formula for Code 128 barcodes
  • Enter a name for the new formula.
Enter formula name - MyCode128Barcode

Step 2. Locate the Code 128 Functions

  • The functions may be listed under one of these two locations:
    Functions > Additional Functions > Visual Basic UFLs (u2lcom.dll)
    Functions > Additional Functions > COM and .NET UFLs (u212com.dll)
  • See here for function descriptions
Enter formula name - MyCode128Barcode

Step 3a. (For Text Fields): Enter the function name in Formula Editor

  • If your data field is text (string), enter the function as below:
  • Code128B({Items.item_barcode})
  • Items.item_barcode is the name of the table and field from your data source.
  • Click on Save and close. Continue to Step 4.
Add Function Name to Crystal

Step 3b. (For Numeric Fields): Enter the function name in Formula Editor

  • If your data field is numeric, it must be converted to text. This is done using the Crystal Function ToText(), as below:
  • Code128B (ToText({Items.item_price}, 0, ''))
  • Items.item_barcode is the name of the table and field from your data source.
  • Click on Save and close.
Add Function Name to Crystal

Step 4. Add a barcode to the report

  • Drag the formula from Field Explorer to the report
Add barcode to the report
  • Change the font properties to:
    Font Name: BCW_Code128B_2
    Font Size: 24
Add barcode to the report

The report is now ready

  • Click on Preview to see or print it.
Print preview the report

Code 128 Fonts Functions in Crystal Reports

Code128Auto()

  • Code128Auto() Encodes data in the most efficient way possible, using a combination of subsets if necessary. Supports all 128 ASCII characters.
  • This function should be used with one of the following fonts:
    BCW_Code128_1 through BCW_Code128_6 (does not show human readable text)
  • This function requires the use of a barcode font without human readable text. However, the text can easily be displayed in a separate formula field with a font such as Arial.
  • To encode a control character, enter it in the format: ^000, where 000 is its digital ASCII value. For example, ABC^009 encodes ABC followed by TAB. To encode FNC1, enter: ^F1

Code128A()

  • Code128A() Encodes data using Code 128 Subset A only. It supports numbers, upper case letters, control characters (such as tab or new-line), space, and the following: !"#$%&'()*+,-./:;<=>?@[\]^_
  • This function should be used with one of the following fonts:
    BCW_Code128A_1 through BCW_Code128A_6 (shows human-readable text under barcode)
    BCW_Code128_1 through BCW_Code128_6 (does not show human readable text)
  • To encode a control character, enter it in the format: ^000, where 000 is its digital ASCII value. For example, ABC^009 encodes ABC followed by TAB. To encode FNC1, enter: ^F1

Code128B()

  • Code128B() Encodes data using Code 128 Subset B only. It supports numbers, upper and lower-case letters, space, and the following characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
  • This function should be used with one of the following fonts:
    BCW_Code128B_1 through BCW_Code128B_6 (shows human-readable text under barcode)
    BCW_Code128_1 through BCW_Code128_6 (does not show human readable text)
  • It is possible to encode control characters using the function Code128B() by temporarily shifting to Subset A. This process is automatic.
  • To encode a control character, enter it in the format: ^000, where 000 is its digital ASCII value. For example, ABC^009 encodes ABC followed by TAB. To encode FNC1, enter: ^F1

Code128C()

  • Code128C() Encodes data using Code 128 Subset C. It supports numbers only and must contain an even number of digits.
  • The digits are encoded in pairs of two, resulting in a barcode about half as wide as subset A or B.
  • This function should be used with one of the following fonts:
    BCW_Code128C_1 through BCW_Code128C_6 (shows human-readable text under barcode)
    BCW_Code128_1 through BCW_Code128_6 (does not show human readable text)
  • To encode FNC1, enter: ^F1