We created this bar-code tutorial to help users of Data Dynamics add barcodes to ActiveReports. Below, we list 3 popular methods of including barcodes in ActiveReports.
Index:
Self-checking Fonts, MICR and OCR fonts (Best method for Code 39)
Visual Basic barcode font module with barcode fonts
ActiveX Control (Best option for UCC-128, EAN-128, PDF417, DataMatrix and MaxiCode)
Method 1 - using Self-Checking Fonts, MICR and OCR fonts
Self-Checking Barcode Fonts, MICR and OCR fonts are compatible with ActiveReports and may be used with ease. To use a self-checking font such as Code 39, you need to insert a "*" before and after the data encoded. Therefore, if you encode AR3OF9 in a barcode, you would need to display the text *AR3OF9* in a field with the Code 39 font selected. In this method, we describe an easy way to do this.
First, you must install one of our Code 39 font packages. We recommend the Code 39 Font Advantage Package because this package includes several fonts in different heights.
Start Visual Basic and open the ActiveReport to which you need to add the barcode.
On the ActiveReport toolbox,
choose the TextBox control and create a text box on your
report that is large enough to include the barcode. Make a
note of its name, in this case it is Field1.

Double-click on a blank area in the report to show the report code.
Add the following code to the
report where Field1 is the name of the TextBox that
will contain the barcode, NumberData is the field
from the database you wish to include in the bar code and
DAODataControl1 is the data control.
Private Sub ActiveReport_FetchData(EOF As Boolean)
If DAODataControl1.Recordset.EOF Then
Exit Sub
Field1.Text = "*" &
DAODataControl1.Recordset("NumberData") & "*"
End Sub
Run the report to make sure the
asterisk is appended to the beginning and end of the data
that is retrieved from the data source.

Go back and edit your
ActiveReport. Change the font of the field to contain the
barcode to one of our Code 39 barcode fonts and run the
report again. You should now see the barcode.

With Code 39, you can also
easily add tabs between two fields in a single barcode (in
extended39) for example:
=("*"&[DataField1] & "$I" &[DataField2]
& "*")
Method 2 - using our Visual Basic barcode font module with barcode fonts
Barcode fonts such as UPC, EAN, Code 128, Interleaved 2 of 5 and MSI require calculations to be performed to determine the check character. To assist our font users with this, we provide a Visual Basic project module. The functions of this module can also be used in an ActiveReport. In this example, we will add UPC/EAN-128 barcodes to a report. For a list of functions included in our module, refer to the function list at our VBA code site.
First, you must install one of our font packages. If you are unsure of which to install, we recommend the Code 128 Font Advantage Package because this package includes several fonts in different heights and it encodes all letters and numbers.
Start Visual Basic and open the ActiveReport to which you need to add the barcode.
In Visual Basic, Choose Project - Add Module.
Select the IDAutomationVBA.bas file.
On the ActiveReport toolbox,
choose the TextBox control and create a text box on your
report that is large enough to include the barcode. In this
example, we are going to include formatted "Human Readable"
text below the barcode as required for UCC/EAN-128
specifications. If you wish to add "Human Readable" text,
add another field and place it on the form. Make a note of
the field names, in this case they are Field1 and
Field2.

Double-click on a blank area in the report to show the report code.
Add the following code to the
report where Code128() is the function,
Field1 is the name of the TextBox that will contain
the barcode, NumberData is the field from the
database you wish to include in the bar code and
DAODataControl1 is the data control.
Private Sub ActiveReport_FetchData(EOF As Boolean)
If DAODataControl1.Recordset.EOF Then
Exit Sub
Field1.Text =
Code128(DAODataControl1.Recordset("ucc128"), 0)
Field2.Text =
Code128(DAODataControl1.Recordset("ucc128"), 1)
End Sub
Run the report to make sure the
data is being pulled from the fields and properly formatted
to the barcode font. You should see that some strange
characters have been appended to the beginning and ending
of the data from the fields - this is normal. Sometimes the
data has to be formatted so much it appears 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
Code128(DAODataControl1.Recordset("ucc128"), 0) formula and
the second one is produced by the
Code128(DAODataControl1.Recordset("ucc128"), 1)
formula.

Go back and edit your ActiveReport. Change the font of the field to contain the barcode to the appropriate barcode font. In this case, we selected the IDAutomationC128M font to create a Code-128 barcode.
Now, when the report is run we
see the barcode created in the field1 text box.

You may include multiple fields
in a single barcode by changing the field formula. For
example, to include two fields (sscc18 and ucc128) in a
single code 128 barcode with a tab function between them we
use the following formula:
Field1.Text = Code128(DAODataControl1.Recordset("sscc18")
& Chr(9) & DAODataControl1.Recordset("ucc128"),
0)
You may use Chr(9) for a tab and Chr(13) for a return.
Method 3 - using the ActiveX Control and DLL with Active Reports
Our ActiveX Control and DLL products may be easily used in ActiveReports. We have linear symbologies available as well as 2D barcodes such as PDF417, Data Matrix and Maxicode. In the example below, we will include a code 128 barcode in a report. Our ActiveX Control is very useful in ActiveReports because the control automatically formats "Human Readable" data for AIs in UCC128 and EAN128 barcode types.
First, you need to install one of our ActiveX Control products.
Start Visual Basic and open the ActiveReport to which you need to add the barcode.

To connect the barcode control
directly to a single data field from your data source,
select or enter the DataField property from the property
window.

To include multiple fields in the same barcode:
In this example, we include two fields (sscc18 and ucc128) in a single code 128 barcode with a tab function between them. When scanned, the scanner will read the tab function which will advance the cursor to another field. The is very useful when you need to populate multiple fields from the scanned data. Usually, PDF417 or DataMatrix is used in this situation because these barcode types can encode hundreds of characters in a single symbol. You can only encode functions between fields in Code 39, Code 128, PDF417, Data Matrix and Maxicode symbologies.
Make sure the control is not bound to a data field - the DataField property in the property window should be blank.
Double-click on a blank area in the report to show the report code.
Add the following code to
the report where "sscc18" and "ucc128" are fields you
wish to include in the bar code and DAODataControl1 is
the data control.
Private Sub ActiveReport_FetchData(EOF As
Boolean)
If DAODataControl1.Recordset.EOF
Then Exit Sub
BarCode1.DataToEncode =
DAODataControl1.Recordset("sscc18") & Chr(9) &
DAODataControl1.Recordset("ucc128")
End Sub
You may use Chr(9) for a tab and Chr(13) for a return.
When the report is run, the
barcode will be created.
