Crystal Reports Barcode Formula Tutorial
- Easily create barcodes in Crystal Reports using fonts without
installing UFLs or DLLs.
- Embeds font formatting technology where formulas are saved as part of the report file (.rpt) and do
not have any external dependencies apart from the required barcode
font.
- Compatible with Crystal 8 and up.
- Supports Generation of Code 128, Code 39, Interleaved 2 of 5, UPC, EAN,
Postnet, Planet, Data Matrix, PDF417 and other barcode types.
- Report Custom Functions may be created from IDAutomation's formulas and
placed into the Repository of Custom Functions.
- Source code included.
- Royalty free.
Support |
Native Barcode
Generator |
Font UFL
| Integration
Guide
IDAutomation's Barcode Font Formulas for Crystal Reports are
saved as part of the report file (.rpt) and do not have any external
dependencies (with the exception of the required barcode font). If distributing
the report, IDAutomation suggests using this method or implementation
of the Native
Barcode Generator for Crystal Reports which creates dynamic
embedded barcodes without the installation of any barcode fonts or components.
These formulas are only provided in purchased versions
of some barcode font packages. The formulas have been tested in Crystal
Reports 8 and 9 and are compatible with later versions as well. For
advanced developers using Crystal 9 or above, Report Custom Functions
may be created from IDAutomation's formulas and placed into the Repository
of Custom Functions. Formulas are currently only supplied with the following
font packages:
Each formula is to be used with the font supplied in
the package. Additional formulas for other fonts will most likely not
be created, because the implementation of the
Native Barcode
Generator offers better performance without installing any barcode
fonts or components.
- If not sure which font is needed, IDAutomation
recommends the
Code 128 Font
Advantage Package which can encode numbers and letters
and it is very compact. This Crystal Report Barcode tutorial uses
Code 128. When using Code 128 or
Interleaved 2 of 5, if the character set is not US English, 1252
Latin-1, 1250 European, 1251 Cyrillic, 1253 Greek, 1254 Turkish,
1255 Hebrew or 1256 Arabic, the
Universal
Barcode Font Advantage must be used.
- Purchase and install the appropriate barcode fonts by running
the INSTALL.EXE file if the package contains one.
- Open the Crystal Reports Example from the icon in the program
group or from the "Crystal Reports Formulas" folder of the supplied
ZIP file.
- Open Field Explorer; in version 9, choose View - Field
Explorer. In versions prior to 9,
choose Insert - Formula Field. Right click on the
selected formula field and choose Edit to reveal the formula.
- When the source code is on the screen, place the cursor in the
code and (1) do CTRL-A to select all and then (2) do CRTL-C to copy
the code. Close the report example.
- Open a report. Right click on Formula Fields and select
New.
- In the Formula Name dialog box, enter the name to identify the
formula. This can be any name, for example, "BarcodeFormula." In
this case "Barcode."

- Click OK. The Formula Editor appears.
- If given an option between expert and editor, choose the
Editor.
- Change the syntax of the formula to Basic Syntax.

- Delete any text if it appears in the editor window. Place the
cursor in the editor window and press CTRL-V to paste the new formula
into the window.
- Change the "DataToEncode" statement so it connects to the data
source; for example:
DataToEncode = ({Table.Field})
NOTE: For some double byte language settings such
as Chinese, Korean and Japanese languages, Crystal 9 or greater
must be used, replace every
reference
of Chr with ChrW and Asc with AscW
in the formulas for compatibility. Additionally, the
Universal
Barcode Font should be used if possible.
- If an error such as "A string is required" appears, the data
will need to be converted to a string with a crystal function.
For example: DataToEncode =
cStr( {Employee.EmployeeID},0 )
- If Code 128 is used, another formula may be created to return
the Human Readable text. In this tutorial, the @BarcodeHR formula
was created in the same way as @Barcode, except the Code128TEXT
formula was copied from the Crystal Reports Example.
- Return to the Field Explorer dialog box. Click on the formula
field and drag it onto the report.

- Now that the fields have been created in the report, choose
the Preview tab to make sure the data is being pulled from
the fields and properly formatted to the barcode font. Note: Some
strange characters will append to the beginning and ending of the
data from the fields - this is normal. Sometimes the data has to
be formatted so much that it will appear to be scrambled. This is
normal for Code 128 and Interleaved 2 of 5 when numbers need to
be compressed within the barcode. In the graphic below, the first
string is produced by the @Barcode formula and the second
one is produced by the @BarcodeHR formula which formats text
for the bottom of the barcode.

- Choose the Design tab again and size the Barcode formula
field to display the appropriate barcode font in the report.
- Change the font of the formula field to be the appropriate
barcode font and set the point size to match the scanner specs.
This is a very important step; if this is not done, barcodes will
not be displayed. If unsure of the point size to use, 12 points
is suggested. UPC and EAN fonts should be printed at 22 points or
greater.
NOTE: When selecting the font from the pull down menu, do
not use the fonts that begin with the
"@" Symbol.
Instead, scroll down in the list and select the ones that begin
with "IDAutomation."
- When the Preview tab (or File - Print Preview) is selected,
barcodes should be seen in the report. Print one page of the report
and test with a barcode scanner. If a scanner is needed, IDAutomation
suggests the
IDAutomation USB Barcode Scanner which scans all popular linear,
GS1 DataBar and PDF417 barcodes. When 2D Data Matrix, QR Code, Aztec
or Postal and Intelligent Mail symbols need to be verified, IDAutomation suggests
the 2D USB Barcode Scanner with PQA.

- It is also possible to combine multiple fields and place functions
in a single barcode when using the Code 128 Auto formula in a report.
For example, the following formula combines two fields in a single
barcode and places a tab function between them:
DataToEncode =({Table1.DataField1}
& CHR(9) & {Table1.UPC})
The following formula places a return function after the
barcode: DataToEncode = ({Table1.DataField1}
& CHR(13))
Use CHR(9) for tab
and CHR(13) for a return.
For advanced barcode Crystal Report developers using
version 9 or above, Report Custom Functions may be created from IDAutomation's
formulas and placed into the Repository of Custom Functions. Follow
the procedures provided in the Crystal Reports documentation to create
the function in the formula workshop and paste the formula (obtained
from IDAutomation Formulas for Crystal Reports)
in the function. For example:
Function IDAutomationCode128 (DataToEncode
as String) as String
<<<include source code here that creates the PrintableString from DataToEncode>>
IDAutomationCode128 = PrintableString
End Function
Then in the Crystal Report, simply call the function:
IDAutomationCode128 ( {Table1.DataField1}
)
NOTE: At this time, IDAutomation's support department does not troubleshoot
Report Custom Functions. Please consider attempting to reproduce
the issue with the IDAutomation Formulas
for Barcode Crystal Reports Tutorial to obtain support for a particular
problem with the formulas. If there is a problem working with IDAutomation's
barcode fonts, visit
IDAutomation's Barcode Font Support page. For assistance
with other Crystal reports issues refer to
Crystal Reports Support
Site.
Free product support may be obtained by reviewing articles
that are documented at the
IDAutomation's
Barcode Font Support page and by searching the resolved
Public
Forum Threads.
Priority
phone, email and forum support is also provided up to 30 days
after purchase. Additional
priority
phone, email and forum support may be obtained if the
Priority Support
and Upgrade Subscription is active. For assistance with other Crystal
reports issues refer to
Crystal Reports Support
Site.
|