Printing bar codes in ReportSmith reports

Any database field can be printed automatically as any type of bar code, anywhere in your reports.

Creating a Report Smith macro

- Choose menu Tools | Macro and enter a Macro Name. For example, enter ClientNoBarcode.

- Click New.

In the Edit Macro dialog box the default macro appears;

Sub ClientNoBarcode()
End Sub

- Edit this macro to look like the code below.

Replace FieldName with the name of the field you want to bar code.

Replace BarCodeType with the type of bar code you want. See Specifying a bar code type for more details. For example, to produce a Code 128 bar codes use C128-0.BA.

Replace DisplayErrors with 1 to display any error messages in a message box. Use 0 to disable error messages.

'$Include "CIAXCOM.SBH"
Function ClientNoBarcode()
ClientNoBarcode = BCP("FieldName", "BarCodeType", DisplayErrors)
End Function

For example, to print field ClientNo as a Code 128 bar code and to disable error messages;

'$Include "CIAXCOM.SBH"
Function ClientNoBarcode()
ClientNoBarcode = BCP("ClientNo", "C128-0.BA", 0)
End Function

- Click the Test button and you should see Macro source code compile successful. Click OK.

- Click Save to save your macro, if you want to use it in other reports.

In other reports you can reuse the macro by loading it.

Creating a Derived field

- Choose menu Tools | Derived Fields and enter a Derived Field Name. For example, enter  ClientNoBarcode.

- Click the Derived by ReportBasic Macro check box. Click Add.

- In the Choose A Macro dialog box select your macro. For example, select ClientNoBarcode.

- Click the Derived by Report Macro check box. Click OK.

- Click Done.

Inserting Derived field in report

- Choose menu Insert | Field.

- To list derived fields select Derived Fields in the dropdown box.

- Drag your derived field to your report. For example, drag ClientNoBarcode.

Selecting a bar code font

- Select the field

- Right-click it to bring up the properties box

- Select the font name and font size. See Bar code font name and font size to use for more details.

Sizing bar code fields

If you make fields too small bar codes could accidentally be clipped. To avoid this;

Label Reports - size fields as wide as possible, up to the right side of the label.

Form Reports - size fields as wide as possible, up to the right margin.

Column Reports - size the fields as wide as possible. You may find it useful to print bar codes in the last column and use all remaining space, up to the right margin.

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