BarCodeWiz Logo

Barcodes in MS Access Query

Encode Code 128 Barcodes in an Access Query

  • This tutorial shows how to encode the barcode value directly in a SQL query.
  • The query is based on a data table. It has all the same fields as the table, plus one barcode field.
  • The benefit of this method is the query can be used as data source to an Access Report, Form, or even other programs like MS Word or Publisher.
  • Any software which imports from an Access database can create Code 128 barcodes.

Step 1. Import module with barcode functions.

  • Click on Database Tools tab > Visual Basic (or press Alt + F11).
Open the Visual Basic Editor in Access to import BarCodeWiz Code 128 module

  • Right-click on the database name and select "Import File"...
Right-click project name and select Import File to import BarCodeWizCode128 module

  • Select BarCodeWizCode128.bas.
  • The default location of the file is:
    C:\Program Files\BarCodeWiz\BarCodeWiz Code 128 Fonts
Select BarCodeWizCode128.bas to import module into your project

  • The following module should now be part of the Access file.
Access imported module of BarCodeWiz Code 128 Fonts via Code editor

Step 2. Create a new Table

  • Create a new table or use an existing table. Our table has the following data:
  • item_barcode is a Text field containing the barcode data we will encode.
  • item_name is a Text field with item description
  • item_price is a Number field with the item's price

Step 3. Create a new Query

  • Click on Create tab > Query Design

Step 4. Add our Table

  • Double-click on Items in the Show Table dialog, and click Close.

Step 5. Edit Query

  • Add all items in the first column: Items.*
  • Add a new calculated field to show the encoded barcode:
    MyBarcode: BCW_Code128B([item_barcode])

Step 6. Save the Query and preview

  • The field MyBarcode contains the encoded value of item_barcode. The function BCW_Code128B() encodes the text in Code 128 Subset B; it adds the start/stop characters as well as a calculated check digit.
  • This query may be used anywhere you'd normally use the Items table.
  • To display it as a barcode, simply change the Font Name and Size.

EXAMPLE: Using the query as a data source for a Report

  • Create a new report: Create > Report Wizard

  • Select the ItemsQuery as the source and select all fields.
  • Click Finish and edit the report in Design Mode.

  • Edit the text box to change the Font Name and Size:
    Font Name: BCW_Code128B_1
    Font Size: 20


  • Print Preview the report.