Printing different field types as bar codes

In a report, you can print any database field as an automatic bar code.

See Printing bar codes in Microsoft Access reports for step-by-step instructions.


Simply place a Text Box control in your report and set its Control Source property to an expression which uses a bar code function, like so;

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

and set the controls Font property to the name of an installed bar code font, like so;

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

Note: For each type of bar code, there is a unique function to use and an associated bar code font to select. See Bar code functions and Bar code font name and font size to use.

Any field (Text, Number, Date/Time, Currency, Counter, Yes/No, AutoNumber, etc.) or expression, which evaluates to a string, can automatically print as a bar code.

Formatting database fields

Our product provides the bar code functions you need to print bar codes, but you must format your data, as you require, before it is printed as bar codes.

Here is some helpful advice about how to format different Access field types, before you use the result as the argument to a bar code function.

Text fields

Text fields usually do not require any special formatting. To print field ORDER_NUMBER as a Code 128 bar code we use function CIA_CODE128, like so;

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

Note: If your field has the same name as any Access reserved word (e.g. 'Name', 'Null') you must also including the table name in the calculated field;

Control Source  . . . . . .  =CIA_CODE128( [MyTable!Name] )

Text field concatenation

One typical application requirement is to print bar codes containing more than one field. If ORDER_NUMBER and BATCH_NUMBER are both text fields, you can use simple string concatenation, like so;

Control Source  . . . . . .  =CIA_CODE128( [ORDER_NUMBER] + "," + [BATCH_NUMBER] )

to print a Code 128 bar code containing two fields, separated by a comma.

Number fields

Use the Visual Basic Format( ) function to print numbers in different number formats.

In Microsoft Access Help, see Format function under Visual Basic Language Reference.

For example, to print a numeric value with up to 5 leading zeros and no decimal places;


When you use a bar code function, this will produce numeric bar codes of equal length;

Control Source  . . . . . .  =CIA_CODE128( Format([Field],"00000") )

Date fields

Use Format( ) to print dates in different date formats. For example, to print dates without the date separator;

Format([Field], "YYYYMMDD")

When you use a bar code function, this will reduce the size of date bar codes and also allows you to use bar code types that only allow numeric characters;

Control Source  . . . . . .  =CIA_CODE128 ( Format([Field], "YYYYMMDD") )

Yes/No fields

In Access, the standard Visual Basic function IIF( ), is very useful for printing Access Yes/No fields as any two values. For example, you can use IIF( ) to print a field as Y or N instead of Yes and No, using the following as the Data Source expression;

IIf( [Field]=0, "N", "Y" )

When you use a bar code function, this will produce small bar codes of equal length, containing Y or N;

Control Source  . . . . . .  =CIA_CODE128 ( IIf( [Field]=0, "N", "Y" ) )

If you need other examples, see Technical Support.

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