Printing bar codes in Microsoft Access reports

This section assumes you have added the Visual Basic module to your database. See Import our Visual Basic module in to a database.

Functions in the new module can be used in Access, just like existing Visual Basic functions. For each type of bar code, there is a specific function to use to return the bar code, and a specific font to select to print the bar code.

Step by step

If you are adding bar codes to an existing report, goto Step 2.

1. Design your report in the usual way

In Access, you should first design your report in the usual way, using; Report Wizard, Design View, etc. Create everything you need in your report design, except bar codes.

2. When you have designed your report, then you can add bar codes to your report design.

To open your report in design view;

- Open your database. Select Reports in the Objects list. Select your report and click Design .

To add a bar code to your report, you must first use the toolbox to add a Text Box to the report. If the toolbox is not displayed, to view the toolbox choose menu View | Toolbox .

- Click the Text Box tool in the toolbox.

- Click anywhere on the report page to create a default-sized text box, or drag to create a text box that is the size you want.

We only need the Unbound Text Box object. If you also see a Label object, select the Label object;

and choose menu Edit | Delete (or press the Del key). 

- Select the remaining Unbound Text Box and choose menu View | Properties .

- Click the Other tab and in the Name property, enter a name for the Text Box object. It must be a  unique name, not the name of; a field, another object, function or reserved Visual Basic word.

Name . . . . . . . . . . . .  MyBarcode1

- Click the Data tab and in the Control Source property, enter an expression using one of the new bar code functions in the new module.

Note: For each type of bar code, there is a specific function to use. For Code 128 the function is CIA_CODE128( ).

See: Bar code functions.

For example, to print field [MyField] as a Code 128 bar code, enter this expression;

Control Source  . . . . . .  =CIA_CODE128( [MyField] )

and press ENTER.

Using the Expression Builder

An alternative way to enter the Control Source expression is to use the Expression Builder. The new bar code functions appear in the expression builder and so do the names of your fields.

To use the Expression Builder, place the cursor Control Source property field and click .

See: Using the Expression Builder.

Testing the report

Before we select the bar code font, you should test the report to see the result of the bar code function;

- To save the report choose menu File | Save.

- To view the report choose menu File | Print Preview .

Because we have not yet selected that correct bar code font the bar code field will print as text. When your Print Preview the report, the bar code field appears as 'strange' text characters. 


This is an example, your result may differ. Each bar code function displays different text characters.

Note: If you see Access error message #Name? or #Error? in your report, or you are prompted to enter a value, then you have made a mistake in your report.

See: Troubleshooting to discover the possible cause and solution.

Selecting a bar code font

Note: For each bar code function, there is a font and font size to use. 

See: Bar code font name and font size to use to discover the font and font size to select.

- Select the field and choose menu View | Properties .

- Click the Format tab and set the Font Name and Font Size properties;

Font Name  . . . . . . . .  CIA Code 128 Medium  
Font Size . . . . . . . . .  14  

The result of bar code functions only appears as a bar code, when you select the correct bar code font and you print or print preview the report.

- To save the report choose menu File | Save.

- To view the report choose menu File | Print Preview .

Sizing the field

To avoid any chance that the bar code might be clipped, size the field as wide as possible; even all the way to the right margin.

- In the object's properties, select Format tab, set the Can Grow property to Yes.

Testing your bar code field

When you print or Print Preview the reports, bar code functions report any errors in a message box.


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.