ActiveReports Barcode FAQ & Tutorial
This ActiveReports barcode tutorial has been created to help users of Data
Dynamics to add barcodes to ActiveReports. Below are the three (3) most
popular methods of creating an Active Reports barcode:
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 barcode
font such as the Code
39 barcode, an asterisk (*) will need to be inserted before and after
the data encoded. Therefore, when encoding 1234567890 in a barcode,
the encoded data display would be*1234567890* prior to applying the
Code 39 font. Below is an easy way to do this:
- First, install the
Code 39 Barcode
Font Advantage Package which includes several fonts in different
heights.
- Start Visual Basic and open the ActiveReport to which a barcode
needs to be added.
- On the ActiveReport toolbox, choose the TextBox control and create
a text box on the 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 needed 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 ActiveReport 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 the ActiveReport. Change the font of the field
to contain the Code 39 barcode fonts and run the report again. A barcode
should appear that looks like this:
- With the Code 39 barcode font, tabs may be easily added 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
IDAutomation's font users with this, a Visual Basic project module is included
with the barcode font package. The functions of this module may also be
used in an ActiveReport. In this example, a UCC/EAN-128 barcode will be
added to a report. For a list of functions included in the module, refer
to the function list at the
VBA code site.
- Install one of the
barcode font packages.
IDAutomation recommends 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 add the barcode.
- In Visual Basic, Choose Project - Add Module.
- Select the IDAutomationVBA.bas file. (Click
here to download the file if not yet installed and save it as IDAutomationVBA.bas.)
- On the ActiveReport toolbox, choose the TextBox control and create
a text box on the report that is large enough to include the barcode.
In this example, the "Human Readable" text below the barcode will be
included as required for UCC/EAN-128 specifications. To add "Human Readable"
text, simply 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 to include
in the bar code and DAODataControl1 is the data control. For
a list of functions included in the module, refer to the function list
at the VBA code
site.
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. There should be some strange
characters that 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 the ActiveReport. Change the font of the field
to contain the appropriate barcode. This method uses the IDAutomationC128M
font to create a Code-128 barcode.
- Now, when the ActiveReport is run, there will be a barcode created
in the field1 text box.
- Multiple fields may be included 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 use the
following formula:
Field1.Text = Code128(DAODataControl1.Recordset("sscc18") & Chr(9) &
DAODataControl1.Recordset("ucc128"), 0)
Use Chr(9) for a tab and Chr(13) for a return.
Method 3 - using the ActiveX
Control and DLL with Active Reports
The ActiveX Control and DLL
products may be easily used in ActiveReports. Linear barcode symbologies
are available as well as 2D barcodes such as PDF417, Data Matrix and Maxicode.
In the example below, a Code 128 barcode will be included in an ActiveReport.
The ActiveX Control is very useful in ActiveReports because the control
automatically formats "Human Readable" data for AIs in UCC128 and EAN128
barcode types.
More
about this...
- First, install the ActiveX Barcode Control.
- Start Visual Basic and open the ActiveReport to add the barcode.
- On the ActiveReport toolbox, choose the more controls button that
looks like this:

Then, select the barcode control from the list of available ActiveX
Controls (it begins with IDAutomation). After selecting it, the barcode
control will appear in the report. The control may be sized as necessary.

- To change the properties of the barcode control such as height and
symbology type, select the control and choose View - Properties
Window.
- To connect the barcode control directly to a single data field from
the data source, select or enter the DataField property from the property
window.
- To include multiple fields in the same barcode:
- In this example, two fields (sscc18 and ucc128) are included
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. This is very useful when populating
multiple fields from the scanned data. Usually, PDF417 or DataMatrix
is used in this situation because these 2D barcodes may encode hundreds
of characters in a single symbol. Functions may only be encoded
between fields in Code 39, Code 128, PDF417, Data Matrix and Maxicode
barcodes.
- Make sure the barcode 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 to be include in the barcode 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
- Use Chr(9) for a tab and Chr(13) for a return.
- When the ActiveReport is run, the barcode will be created.
Reviews
and Listings for this plug-in:
© Copyright 2000-2009 IDAutomation.com,
Inc., All Rights Reserved.
Legal Notices.
|
Over 70% of Fortune 100
companies use IDAutomation's products to automate their businesses.
|
|