ActiveReports Barcode Tutorial & FAQ

This IDAutomation tutorial focuses on helping Data Dynamics users to add barcodes to ActiveReports. The following are three popular methods of creating barcodes in ActiveReports:
  1. Self-Checking Fonts: Best for creating Code 39 barcodes in ActiveReports.
  2. Fonts with a Visual Basic Module: Best for barcodes that do require a check digit.
  3. ActiveX Controls: Best for creating complex barcodes such as UCC-128, EAN-128, PDF417, Data Matrix, and MaxiCode.
Using Self-Checking Fonts in ActiveReports

For self-checking fonts such as Code 39, insert an asterisk (*) before and after the data to be encoded. For example, when encoding 1234567890 in a barcode, the encoded data display will be *1234567890* prior to applying the Code 39 font.

  1. Purchase, download, and install the Code 39 Barcode Font Advantage Package.
  2. Start Visual Basic and open the ActiveReport that requires the barcode.
  3. On the ActiveReport toolbox, choose the TextBox control and create a text box on the report that is large enough to contain the barcode. Make a note of the name; in this case, it is Field1.
    Create a Text Box for the Barcode in ActiveReports
  4. Double-click on a blank area in the report to show the report code.
  5. 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 barcode 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
  6. Run the ActiveReport to make sure the asterisk is at the beginning and end of the data retrieved from the data source.
    Asterisks must appear at the beginning and end of the data for Code 39 barcodes
  7. Edit the ActiveReport and change the font of the field to contain the Code 39 fonts, then run the report again. A barcode should appear as follows:
    Change the Font Field to Code 39 to Create a Readable Barcode
  8. 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] & "*")
Using Fonts with a Visual Basic Module in ActiveReports

Barcode fonts such as UPC, Code 128, Interleaved 2 of 5 and others require calculations to be performed to determine the check character. To make this calculation easier, IDAutomation provides a Visual Basic project module with purchased barcode font packages and the functions of this module may 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 Barcode Macros and VBA Functions page.

  1. Install the IDAutomation barcode font package of your choice. IDAutomation recommends the Code 128 Fonts because the package includes several fonts in different heights, and it encodes all letters and numbers.
  2. Start Visual Basic and open the ActiveReport.
  3. In Visual Basic, Choose Project - Add Module.
  4. Select the IDAutomationVBA.bas file.
  5. On the ActiveReport toolbox, choose the TextBox control and create a text box on the report that is large enough to contain 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.
    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.
  6. Double-click on a blank area in the report to show the report code.
  7. 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 Barcode Macros and VBA Functions page.
    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
  8. Run the report to confirm the data is pulled from the fields and is properly formatted to the barcode font. There should be some characters that have been appended to the beginning and end of the data from the fields. Sometimes the data has to be formatted so much that it appears scrambled, and 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.
    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.
  9. Edit the ActiveReport and change the field font to the appropriate barcode font. This method uses the IDAutomationC128M font to create a Code-128 barcode.
  10. When the ActiveReport is run, there will be a barcode created in the field1 text box.
    UCC-128 / EAN-128 barcodes created in ActiveReports
  11. 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.
Using The ActiveX Control & DLL in ActiveReports

The IDAutomation ActiveX Control and DLL 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.

  1. Purchase, download, and install the ActiveX Barcode Control.
  2. Start Visual Basic and open the ActiveReport to add the barcode.
  3. On the ActiveReport toolbox, choose the More Controls icon:
    The more controls button
  4. Select the barcode control from the list of available ActiveX Controls that begins with IDAutomation and the barcode control will appear in the report. The control may be sized as necessary.
    Select the barcode control from the list of available ActiveX Controls (it begins with IDAutomation). After selecting it, the control will appear in the report.
  5. To change properties of the control such as height and barcode type, select the control and choose View - Properties Window.
  6. To connect the control to a single data field from the data source, select or enter the DataField property from the property window.
    To connect the barcode control directly to a data field from your data source, select or enter the DataField property from the property window.
  7. To include multiple fields in the same barcode:
    1. 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.
    2. Make sure the barcode control is not bound to a data field and that the DataField property is blank.
    3. Double-click on a blank area in the report to show the report code.
    4. Add the following code to the report where "sscc18" and "ucc128" are fields to be included 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
    5. Use Chr(9) for a tab and Chr(13) for a return.
  8. When the ActiveReport is run, the barcode will be created.
    ActiveReports Barcode Using ActiveX Controls