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.
![](https://media.barcodewiz.com/images/7cc83686-c655-45c1-92fd-37b2a50f2661-qr-access-tlv_THUMB.png)
Step 1A. Add TLV function to your access file
- Click on Database Tools tab > Visual Basic (or press Alt + F11).
![](https://media.barcodewiz.com/images/b768420a-29f2-4d02-9a84-9ba541cf0127-qr-access2.png)
- Right-click the database and select Insert / Module.
![](https://media.barcodewiz.com/images/01103039-a116-4e01-99a4-b08fd2fa0ee5-qr-access-tlv_008.png)
- 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)) Else AppendByte bytes, CByte(tags(v)) 'Tag End If AppendByte bytes, CByte(leng) 'Length AppendBytes bytes, thisB 'Value Next 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) Next End Function
- Click on Save button (or press Ctrl + S on your keyboard)
![](https://media.barcodewiz.com/images/a6e6646c-e292-48b1-8f2c-8ec48143895a-qr-access-tlv_006.png)
- Name the module: TLVModule
![](https://media.barcodewiz.com/images/22553014-8133-490f-9e8c-5d10b91b3a27-qr-access-tlv_009.png)
Step 1B. Import module with barcode functions
- Again, click on Database Tools tab > Visual Basic (or press Alt + F11).
![](https://media.barcodewiz.com/images/b768420a-29f2-4d02-9a84-9ba541cf0127-qr-access2.png)
- Right-click the database and Import File...
![](https://media.barcodewiz.com/images/6cbd9922-ba4a-4d94-9a89-dad7fecca29f-qr-access-tlv_001.png)
- Select BarCodeWizQrCode.bas
- The default location of the file is:
Program Files\BarCodeWiz\BarCodeWiz QR Code Fonts\BarCodeWizQrCode.bas
![](https://media.barcodewiz.com/images/315fd1f4-dc98-41ed-b55b-2615a2cb0d2e-qr-access4.png)
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:
![](https://media.barcodewiz.com/images/39ca1b8b-609f-43e2-94ea-23c2247b50b5-qr-access-tlv_002.png)
Step 3. Create a new report in Design Mode
- Click on Create tab > Report Design
![](https://media.barcodewiz.com/images/b5ba853a-a5db-4267-9173-456b08b299f2-qr-access-tlv_003.png)
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).
![](https://media.barcodewiz.com/images/429bcd85-d463-4bee-b0a2-a03010472c61-qr-access-tlv_004.png)
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])
![](https://media.barcodewiz.com/images/6ebe1bfd-e3f4-4bc1-8cc7-42aefa9991e4-qr-access-tlv_005.png)
- Can Grow: Yes
![](https://media.barcodewiz.com/images/7e2c1406-1ee0-47ea-9b78-8f368e407285-qr-access10.png)
- Border Style: Transparent
- Font Name: BCW_QR
- Font Size: 8
![](https://media.barcodewiz.com/images/9a07d466-990e-4685-a00f-40fffc2d2218-qr-access11_1.png)
Step 6. Print or Print Preview the report.
- The report is ready to save or print.
![](https://media.barcodewiz.com/images/87587337-bbcf-4a83-8621-7d5a81187ed2-qr-access-tlv_007.png)