BarCodeWiz Logo

Create QR Code Barcodes in TLV Format in Access

How To Create QR Code Barcodes in TLV format in Access

  • This tutorial shows how to add QR Code barcodes in TLV format to your MS Access reports. The barcodes are generated using BarCodeWiz QR Code Fonts.
  • We are going to use the following example file included with our fonts: QrCodeAccess_Example. You can use your own data.
  • Watch the video or follow the steps below.

Step 1A. Add TLV function to your access file

  • Click on Database Tools tab > Visual Basic (or press Alt + F11).

  • Right-click the database and select Insert / Module.

  • Copy the following text and paste it into the editor window:
    Function Tlv(sellersName As String, vatNumber As String, timestamp As Date, invoiceTotal As String, vatTotal As String)
        Static bcwiz As Object
        If bcwiz Is Nothing Then
           Set bcwiz = CreateObject("BarCodeWizFonts.QrCode.QrCodeFonts")
        End If
        Dim tags(4) As Integer
        tags(0) = 1
        tags(1) = 2
        tags(2) = 3
        tags(3) = 4
        tags(4) = 5
        Dim values(4) As String
        values(0) = sellersName
        values(1) = vatNumber
        values(2) = format(timestamp, "yyyy-MM-ddThh:mm:ssZ")
        values(3) = invoiceTotal
        values(4) = vatTotal
        Dim bytes() As Byte
        ReDim bytes(0)
        Dim v As Integer
        For v = LBound(values) To UBound(values)
            Dim thisB() As Byte
            thisB = bcwiz.GetEncodingAsBytes(values(v), "UTF-8")
            Dim leng As Integer
            leng = UBound(thisB) - LBound(thisB) + 1
            If UBound(bytes) = 0 Then
                bytes(0) = CByte(tags(v))
                AppendByte bytes, CByte(tags(v))  'Tag
            End If
            AppendByte bytes, CByte(leng) 'Length
            AppendBytes bytes, thisB        'Value
        Dim base64 As String
        base64 = bcwiz.BytesToBase64(bytes)
        Tlv = QrCodeEncode(base64, 1, 1, True, 4)
    End Function
    Private Function AppendByte(ByRef arr() As Byte, ByRef b As Byte)
        Dim bytes(0) As Byte
        bytes(0) = b
        AppendBytes arr, bytes
    End Function
    Private Function AppendBytes(ByRef arr() As Byte, ByRef bytesToAppend() As Byte)
        Dim orgSize As Integer
        orgSize = UBound(arr) - LBound(arr) + 1
        Dim appendSize As Integer
        appendSize = UBound(bytesToAppend) - LBound(bytesToAppend) + 1
        ReDim Preserve arr(orgSize + appendSize - 1)
        Dim i As Integer
        For i = 0 To appendSize - 1
            arr(orgSize + i) = bytesToAppend(i)
    End Function

  • Click on Save button (or press Ctrl + S on your keyboard)

  • Name the module: TLVModule

Step 1B. Import module with barcode functions

  • Again, click on Database Tools tab > Visual Basic (or press Alt + F11).

  • Right-click the database and Import File...

  • Select BarCodeWizQrCode.bas
  • The default location of the file is:
    Program Files\BarCodeWiz\BarCodeWiz QR Code Fonts\BarCodeWizQrCode.bas

Step 2. Create a new table (or use an existing table)

  • Create a new table with barcode data. Name it TLVTable (or simply use an existing table). Our table has the following data:

Step 3. Create a new report in Design Mode

  • Click on Create tab > Report Design

Step 4. Set Record Source of the report

  • Go to report Properties window and set the Record Source property to TLVTable (the name of our table from step 2).

Step 5. Insert a TextBox for Barcode into the Detail section or the report. Set these properties:

  • Control Source: =Tlv([sellersName],[vatNumber],[timestamp],[invoiceTotal],[vatTotal])

  • Can Grow: Yes

  • Border Style: Transparent
  • Font Name: BCW_QR
  • Font Size: 8

Step 6. Print or Print Preview the report.

  • The report is ready to save or print.