Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Media » WklBarcode » Print labels with a QR code

Print labels with a QR code

In this tutorial, you print one label per item, each showing the item number as text and as a QR code, and save the labels as a PDF.

Prerequisites

  • Access in Microsoft 365 or the Access Runtime, 32-bit or 64-bit, with the WKL Forms Object Library 1.52 or later installed and registered for the current Windows user (How to: Install the released package).
  • A new or existing database in a trusted location.
  • Every WKL control opens its designer the same way: in Design view, open the property sheet (F4), select the Other tab, and click [...] in the Custom row (How to: Open the designer of a control).

Steps

1. Create the sample table

Paste this procedure into a standard module and run it once from the Immediate window (CreateLabelSample):

Public Sub CreateLabelSample()
    Dim i As Long
    With CurrentDb
        .Execute "CREATE TABLE tblItems (ID COUNTER CONSTRAINT PK_Items PRIMARY KEY, ItemNo TEXT(20), Description TEXT(50))"
        For i = 1 To 6
            .Execute "INSERT INTO tblItems (ItemNo, Description) VALUES ('WKL-" & (4710 + i) & "', 'Item " & i & "')"
        Next
    End With
End Sub

2. Create the report and insert the code

In Design view, create a report named rptLabel that's bound to tblItems. Make the Detail section about 1.4 in. tall and add an ItemNo text box and a Description text box. Choose Report Design › Controls › ActiveX Controls › WKL Barcode, draw the control to the left of the text boxes, about 1.2 in. wide and 1.2 in. tall, and name it bcdItem. Set its Control Source (property sheet, Data tab) to ItemNo.

3. Set the code

Open the designer for bcdItem ([...] in the Custom row). On the Code page, keep the QR code type, turn on Show text, and enter WKL-4711 as the sample text; the preview shows the code with the number below it. Click OK to close the designer, and save the report.

4. Look at the labels

Open rptLabel in Print Preview. Each label shows the QR code of its own item number; a phone camera or a scanner reads WKL-4711, WKL-4712, and so on.

5. Save the labels as a PDF

Run this line in the Immediate window:

DoCmd.OutputTo acOutputReport, "rptLabel", acFormatPDF, CurrentProject.Path & "\Labels.pdf"

Expected result

A report with six labels, each with its item number as text and as a scannable QR code, and the same labels in Labels.pdf.

Next steps

  • For scanners that read only linear barcodes, choose Code 128 (Symbology = wsyCode128), and give the control the width of the label and a height of about 0.6 in.
  • To save a code as an image file for other programs, use SaveImage (API reference: WklBarcode).
en/wiki/msaccess/comctl/media/barcode/tutorial.txt · Last modified: by Wolfgang van der Stille