In the following tutorial we start with a blank report. In the report we have already created several report fields reflecting database fields. We now add the barcode to the report.
Procedure 5.1. Steps to add barcode to Crystal Reports
Define the barcode trunk fields. A barcode trunk field is a formula field. Most likely you know what it is. To create a formula field, we need to enter the design view. It can be done by choosing | or simply pressing CTRL+D.
If the Field Explorer is invisible, select | to have it appear in the workspace.
- Right click on the Formula Fields. From the context menu, select to add a formula field.
- Give a name to this new field. In our case we call it barcode_trunk1. You can use any names compatible with your naming convention.
- Click on the button. The Formula Editor pops up. Find Morovia barcode functions under the Additional Functions | Visual Basic UFLs section.
-
Select the the function MoroviaDataMatrixEncode,
double click it to make
it appear in the bottom panel. Move the cursor in between the parenthesis.
Put the data field you want to encode. In our case, we put {TestData.Data}
because that filed is what we want to present in barcode form. Note that
this field must be a text string. You can use Crystal Reports function
ToTextto convert other formats into text string. Move the cursor to the next field, and type 1. - Dismiss the Formula Editor and return to the Field Explorer dialog.
-
Based on the calculation from the
GUI Encoder, we know that it takes about 300 characters for the result. As a result we need two trunks to hold all the barcode string. We repeat the steps above and add another formula fieldbarcode_trunk2. - Add a text field (also called memo field) to the report. You can do this by selecting the text field from tool bar and dragging it to the report.
-
Click on the text field to select it.
From the Field Explorer,
drag and drop Formula Field,
barcode_trunk1into the text field. -
Drag and drop barcode_trunk2 to the same text field.
Crystal Reports puts
{@barcode_trunk1}{@barcode_trunk2}into the text field. -
Format the text field with
MRV DataMatrixfont. To do this you can right click the text field and select to pop up the format property sheet. -
Click on the Preview tab. The bar code should appear immediately.
We have
successfully build a report with barcode in minutes!
If you are using the trial version, a dialog will pop up to remind
you that you are using a trial version of the software,
and all barcodes contain additional text
DEMOwhen scanned. This limitation will go away once you purchase the retail version.