Adding bar codes to 4D Quick reports

This section assumes you have installed our bar code fonts and our bar code plug-in. See: Install bar code plug-in in 4D

Functions in the new bar code plug-in can be used in 4D Quick reports, just like standard functions in 4th Dimension. There is a specific function to calculate each type of bar code, and a specific font (or set of fonts) to use to print each type of bar code.

Note: All 4D field types and variable types (Alpha, Text, Real, Long Integer, Date, Integer, Time, Boolean, etc.) can be printed as bar codes. Standard 4D functions like; String(exp; "format"), etc. are used to format fields and variable values as strings, so they can be used as the string argument to a bar code function.

Step-by-step

This following sections assumes that you have already created a Quick report and the Quick report is open. See: Creating 4D Quick reports

Add or insert a new column

With your Quick report open.

To display bar codes in a column, we must add or insert a new column;

- Choose menu Column | Add, or menu Column | Insert

When you add a column you will see the Formula Editor dialog box.

Using the Formula Editor

Formulas can be typed, or pasted in to the Formula Editor. To assist you to quickly enter field names and function names in to your formulas, you can double-click their names from lists below the formula.

To make a Quick report column simply display a field, just enter the field name as the formula. The following example formula, displays field [Table 1]AnInteger (i.e. a field called AnInteger in a table called Table 1).

[Table 1]AnInteger

To enter a field name quickly, you can double-click the field name in the Related Fields list (or Master Table list, or All Tables list).

If you wanted to display a column, so that it is formatted with leading zeros, you can use the String function. The formula would then be;

String([Table 1]AnInteger;"0000000")

The String function a standard 4D function, listed under the String theme (along with other sting functions).

Selecting a bar code function

You can quickly enter the name of a bar code function by double-clicking it from the list below the Barcode_CIAXCOM theme. Theme Barcode_CIAXCOM is listed under the Commands by Themes list (or Commands by Alphabetical Order list).

Note: For each type of bar code, there is a specific function to use. For most applications Code 128 bar code are recommended, especially instead of Code 39. To produce Code 128 bar codes, simply use function CIA_CODE128( ) instead of CIA_CODE128( ).

See: Bar code functions.
See: Bar code font name and font size to use for more background information about each bar code type.
See: Advice for printing UCC-EAN-128 bar codes

The command themes of each plug-in is listed after all of the standard 4D command themes, so the Barcode_CIAXCOM theme is listed at the end, with other plug-in command themes.

This formula produces a Code 128 bar code of field AnInteger in table Table 1, by using function CIAXCOM_CODE128 with an argument of [Table 1]AnInteger

CIAXCOM_CODE128([Table 1]AnInteger)

or better still, if we want all of the bar codes to contain zero padded values;

CIAXCOM_CODE128(String([Table 1]AnInteger;"0000000"))

When using complex formulas, test the result of each element of the formula. For example, before using the above formula, test the result of the String function is what you expected;

String([Table 1]AnInteger;"0000000")

Some bar code functions (i.e. CIAXCOM_UPCA, CIAXCOM_EAN13, etc.) require a fixed number of numeric digits in the data string argument. This is because some bar code standards only supports a fixed number of digits. So, if you are creating this type of bar code, it is wise to check that all of the values you produce are all of the correct length.

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 (or File | Save As)
- To view the report choose menu File | Print Preview...

Because we have not yet selected a bar code font, the bar code field will print as strange text characters;

>l1l8[NY9]#

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

Selecting a bar code font

- Under your new column highlight the cell on the Detail row by selecting it.

- Right-click the highlighted cell and from the pop-up menu select Font, then select the correct font.
- Right-click the highlighted cell and from the pop-up menu select Size, then select the correct font size to use.

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

See: Bar code functions to to quickly discover the font and font size to select.
See: Bar code font name and font size to use for more background information about each bar code type.

In this example we are using function CIAXCOM_CODE128, so we must use a font that begins with CIA Code 128

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

- To save the report choose menu File | Save (or File | Save As)
- To view the report choose menu File | Print Preview...

Sizing the field

To avoid any chance that the bar code might be wrapped on to multiple lines (which would be an error), size the column as big as possible.

Testing your bar code field

When you print or Print Preview your reports, if no bar codes appear do the following;

- If you are using a field as the argument of a bar code function, then while you are testing your report, print this field as a separate column of your report; so that you can see what the contents of the field are.

- Print Preview the report and check the field contains data characters of the correct length and type for use with the bar code function you are using.

See: Bar code font name and font size to use for more background information about each type of bar code and the data characters they support, and any length requirements or limitations.

TIP: Temporarily change the argument you are using for the bar code function;

CIAXCOM_CODE128 ( [MyTable].MyField )

to a fixed example, so see if the problem is the argument;

CIAXCOM_CODE128 ( "123456789" )

- If you are using a complex expression as the argument of a bar code function, then while you are testing your report, print this complex expression as a separate column of your report. Check the result of the expression contains data characters of the correct length and type.

If you need further help see Technical Support. The most common cause of errors is incorrect or blank data in fields, or incorrect arguments to bar code functions.

 

 


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