Home:  Products:  ActiveReports Barcode FAQ & Tutorial:

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:

  1. First, install the Code 39 Barcode Font Advantage Package which includes several fonts in different heights.
  2. Start Visual Basic and open the ActiveReport to which a barcode needs to be added.
  3. 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.
    On the ActiveReport toolbox, choose the TextBox control and create a text box on your report that is large enough to include the barcode.
  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 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
  6. 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.
    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.
  7. 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:
    Change the font of the field to contain the barcode to one of our Code 39 barcode fonts and run the report again.
  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] & "*")

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.

  1. 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.
  2. Start Visual Basic and open the ActiveReport to add the barcode.
  3. In Visual Basic, Choose Project - Add Module.
  4. Select the IDAutomationVBA.bas file. (Click here to download the file if not yet installed and save it as IDAutomationVBA.bas.)
  5. 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.
    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 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
  8. 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.
    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.
  9. 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.
  10. Now, 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.

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...
  1. First, 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 button that looks like this:
    The more controls button
    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.
    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.
  4. To change the properties of the barcode control such as height and symbology type, select the control and choose View - Properties Window.
  5. 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 connect the barcode control directly to a data field from your data source, select or enter the DataField property from the property window.
  6. 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 - the DataField property in the property window should be 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 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
    5. Use Chr(9) for a tab and Chr(13) for a return.
  7. When the ActiveReport is run, the barcode will be created.
    When the report is run, the barcode will be created.

To sign up for monthly updates about new products or upgrades, please click here.Reviews and Listings for this plug-in:

 

© Copyright 2000-2008 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.